Class IntegerSet
- All Implemented Interfaces:
Iterable<Integer>,PrimitiveBeanCollection<Integer>
public class IntegerSet extends AnchorBean<IntegerSet> implements PrimitiveBeanCollection<Integer>
A bean defining a set of
Integers.
The elements are stored internally in a consistent ordering, according to their natural comparator.
An example:
<datasets config-class="org.anchoranalysis.bean.primitive.IntegerSet" config-factory="integerSet">
<item>1</item>
<item>-4</item>
<item>8</item>
</datasets>
- Author:
- Owen Feehan
-
Constructor Summary
Constructors Constructor Description IntegerSet()IntegerSet(Integer... values)Constructs with one or more values added to the list. -
Method Summary
Modifier and Type Method Description voidadd(Integer value)Add an element to the collection.protected booleancanEqual(Object other)booleancontains(Integer value)Whether the collection contains a particular element?IntegerSetduplicateBean()Duplicate the bean.booleanequals(Object o)inthashCode()booleanisEmpty()Whether the collection is empty or not.Iterator<Integer>iterator()Set<Integer>set()The underlying set of values.Stream<Integer>stream()Creates a stream of elements in the set.Methods inherited from class org.anchoranalysis.bean.AnchorBean
checkMisconfigured, describeBean, describeChildren, fields, findFieldsOfClass, getBeanName, getLocalPath, localise, toString
-
Constructor Details
-
IntegerSet
Constructs with one or more values added to the list.- Parameters:
values- the values
-
IntegerSet
public IntegerSet()
-
-
Method Details
-
add
Description copied from interface:PrimitiveBeanCollectionAdd an element to the collection.- Specified by:
addin interfacePrimitiveBeanCollection<Integer>- Parameters:
value- the element to add.
-
contains
Description copied from interface:PrimitiveBeanCollectionWhether the collection contains a particular element?- Specified by:
containsin interfacePrimitiveBeanCollection<Integer>- Parameters:
value- the element to search for- Returns:
- true iff the collection contains the element.
-
iterator
-
isEmpty
public boolean isEmpty()Description copied from interface:PrimitiveBeanCollectionWhether the collection is empty or not.- Specified by:
isEmptyin interfacePrimitiveBeanCollection<Integer>- Returns:
- true iff the collection contains zero elements.
-
stream
Creates a stream of elements in the set.- Returns:
- a newly created stream.
-
duplicateBean
Duplicate the bean.NOTE: We need to specifically-implement it as the
AnchorBeanfunctionality won't work with this implementation, as it uses non-default initialization (using a config-factory).- Overrides:
duplicateBeanin classAnchorBean<IntegerSet>- Returns:
- the newly created bean
-
equals
-
canEqual
-
hashCode
public int hashCode() -
set
The underlying set of values.
-