Package uk.gov.gchq.gaffer.commonutil
Class OneOrMore<T>
- java.lang.Object
-
- uk.gov.gchq.gaffer.commonutil.OneOrMore<T>
-
- Type Parameters:
T
- the iterable type.
- All Implemented Interfaces:
Iterable<T>
public class OneOrMore<T> extends Object implements Iterable<T>
AOneOrMore
in anIterable
that allows items to be added. It wraps anArrayList
orHashSet
depending on whether deduplication is enabled. This class is designed to be used in the case when the iterable quite often just contains a single item. In the case only a single item is required, the class doesn't instantiate the Collection it just holds onto the single item. If additional items are added then a new backing collection is created to hold the multiple values.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(T item)
boolean
addAll(Collection<? extends T> items)
boolean
contains(Object o)
boolean
equals(Object obj)
int
hashCode()
boolean
isEmpty()
Iterator<T>
iterator()
void
removeAnyItem()
int
size()
String
toString()
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
OneOrMore
public OneOrMore()
-
OneOrMore
public OneOrMore(boolean deduplicate)
-
OneOrMore
public OneOrMore(boolean deduplicate, T item)
-
-
Method Detail
-
add
public boolean add(T item)
-
addAll
public boolean addAll(Collection<? extends T> items)
-
removeAnyItem
public void removeAnyItem()
-
size
public int size()
-
isEmpty
public boolean isEmpty()
-
contains
public boolean contains(Object o)
-
-