org.omnaest.utils.structure.collection.set.decorator
Class LockingSetDecorator<E>
java.lang.Object
org.omnaest.utils.structure.collection.set.decorator.SetDecorator<E>
org.omnaest.utils.structure.collection.set.decorator.LockingSetDecorator<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- Serializable, Iterable<E>, Collection<E>, Set<E>
public class LockingSetDecorator<E>
- extends SetDecorator<E>
SetDecorator which uses a Lock to synchronize all of its methods. The iterator() method will return a
locked Iterator which uses the same Lock instance.
- Author:
- Omnaest
- See Also:
SetUtils.locked(Set, Lock),
SetUtils.lockedByReentrantLock(Set),
Serialized Form
| Fields inherited from class org.omnaest.utils.structure.collection.set.decorator.SetDecorator |
set |
lock
protected final Lock lock
LockingSetDecorator
public LockingSetDecorator(Set<E> set,
Lock lock)
- Parameters:
set - lock - - See Also:
LockingSetDecorator
LockingSetDecorator
public LockingSetDecorator(Set<E> set)
- Uses a new
ReentrantLock instance as Lock
- Parameters:
set - - See Also:
LockingSetDecorator
size
public int size()
- Specified by:
size in interface Collection<E>- Specified by:
size in interface Set<E>- Overrides:
size in class SetDecorator<E>
- See Also:
Set.size()
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<E>- Specified by:
isEmpty in interface Set<E>- Overrides:
isEmpty in class SetDecorator<E>
- See Also:
Set.isEmpty()
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E>- Specified by:
contains in interface Set<E>- Overrides:
contains in class SetDecorator<E>
- See Also:
Set.contains(java.lang.Object)
iterator
public Iterator<E> iterator()
- Specified by:
iterator in interface Iterable<E>- Specified by:
iterator in interface Collection<E>- Specified by:
iterator in interface Set<E>- Overrides:
iterator in class SetDecorator<E>
- See Also:
Set.iterator()
toArray
public Object[] toArray()
- Specified by:
toArray in interface Collection<E>- Specified by:
toArray in interface Set<E>- Overrides:
toArray in class SetDecorator<E>
- See Also:
Set.toArray()
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray in interface Collection<E>- Specified by:
toArray in interface Set<E>- Overrides:
toArray in class SetDecorator<E>
- See Also:
java.util.Set#toArray(T[])
add
public boolean add(E e)
- Specified by:
add in interface Collection<E>- Specified by:
add in interface Set<E>- Overrides:
add in class SetDecorator<E>
- See Also:
Set.add(java.lang.Object)
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<E>- Specified by:
remove in interface Set<E>- Overrides:
remove in class SetDecorator<E>
- See Also:
Set.remove(java.lang.Object)
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll in interface Collection<E>- Specified by:
containsAll in interface Set<E>- Overrides:
containsAll in class SetDecorator<E>
- See Also:
Set.containsAll(java.util.Collection)
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll in interface Collection<E>- Specified by:
addAll in interface Set<E>- Overrides:
addAll in class SetDecorator<E>
- See Also:
Set.addAll(java.util.Collection)
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll in interface Collection<E>- Specified by:
removeAll in interface Set<E>- Overrides:
removeAll in class SetDecorator<E>
- See Also:
Set.removeAll(java.util.Collection)
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll in interface Collection<E>- Specified by:
retainAll in interface Set<E>- Overrides:
retainAll in class SetDecorator<E>
- See Also:
Set.retainAll(java.util.Collection)
clear
public void clear()
- Specified by:
clear in interface Collection<E>- Specified by:
clear in interface Set<E>- Overrides:
clear in class SetDecorator<E>
- See Also:
Set.clear()
equals
public boolean equals(Object o)
- Specified by:
equals in interface Collection<E>- Specified by:
equals in interface Set<E>- Overrides:
equals in class SetDecorator<E>
- See Also:
Set.equals(java.lang.Object)
hashCode
public int hashCode()
- Specified by:
hashCode in interface Collection<E>- Specified by:
hashCode in interface Set<E>- Overrides:
hashCode in class SetDecorator<E>
- See Also:
Set.hashCode()
toString
public String toString()
- Overrides:
toString in class SetDecorator<E>
Copyright © 2013. All Rights Reserved.