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>
AOneOrMorein anIterablethat allows items to be added. It wraps anArrayListorHashSetdepending 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 booleanadd(T item)booleanaddAll(Collection<? extends T> items)booleancontains(Object o)booleanequals(Object obj)inthashCode()booleanisEmpty()Iterator<T>iterator()voidremoveAnyItem()intsize()StringtoString()-
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)
-
-