Package com.tagtraum.core.util
Class VetoableModificationSet<T>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- java.util.HashSet<T>
-
- com.tagtraum.core.util.VetoableModificationSet<T>
-
- Type Parameters:
T
- element type
- All Implemented Interfaces:
Serializable
,Cloneable
,Iterable<T>
,Collection<T>
,Set<T>
public abstract class VetoableModificationSet<T> extends HashSet<T>
HashSet
that calls methods before adding or removing elements from its collection.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description VetoableModificationSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T element)
boolean
addAll(Collection<? extends T> collection)
void
clear()
protected boolean
internalAdd(T element)
Use this method to add elements without checking for vetoes.protected boolean
internalAddAll(Collection<? extends T> c)
Use this method to add elements without checking for vetoes.protected boolean
isAddable(T element)
Is called before the given element is actually added to this collection.protected boolean
isRemovable(Object o)
Is called before the given object is actually removed from this collection.Iterator<T>
iterator()
boolean
remove(Object o)
String
toString()
-
Methods inherited from class java.util.AbstractSet
equals, hashCode, removeAll
-
Methods inherited from class java.util.AbstractCollection
containsAll, retainAll, toArray, toArray
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, stream, toArray
-
-
-
-
Method Detail
-
internalAdd
protected boolean internalAdd(T element)
Use this method to add elements without checking for vetoes.- Parameters:
element
- element
-
internalAddAll
protected boolean internalAddAll(Collection<? extends T> c)
Use this method to add elements without checking for vetoes.- Parameters:
c
- collection
-
add
public boolean add(T element)
-
remove
public boolean remove(Object o)
-
addAll
public boolean addAll(Collection<? extends T> collection)
- Specified by:
addAll
in interfaceCollection<T>
- Specified by:
addAll
in interfaceSet<T>
- Overrides:
addAll
in classAbstractCollection<T>
-
clear
public void clear()
-
isAddable
protected boolean isAddable(T element)
Is called before the given element is actually added to this collection. You may also use this method to notify another object of the pending addition.- Parameters:
element
- object to add- Returns:
- return
true
, if you want the element to be added,false
otherwise
-
isRemovable
protected boolean isRemovable(Object o)
Is called before the given object is actually removed from this collection. You may also use this method to notify another object of the pending removal.- Parameters:
o
- object to remove- Returns:
- return
true
, if the given element can be removed,false
otherwise
-
toString
public String toString()
- Overrides:
toString
in classAbstractCollection<T>
-
-