Package org.immutables.ordinal
Class OrdinalDomain<E extends OrdinalValue<E>>
- java.lang.Object
-
- org.immutables.ordinal.OrdinalDomain<E>
-
- Type Parameters:
E- type with ordinal values
- All Implemented Interfaces:
java.lang.Iterable<E>
- Direct Known Subclasses:
InterningOrdinalDomain
@ThreadSafe public abstract class OrdinalDomain<E extends OrdinalValue<E>> extends java.lang.Object implements java.lang.Iterable<E>Ordinal domain represent (potentially growing) set of objects of some kind (amongE) which has distinct and contiguous range ofordinalvalues. Equal objects expected to have same ordinal value. Usually, ordinal values will be interned inOrdinalDomain, but it is not strictly required.Implementations must be thread safe.
-
-
Constructor Summary
Constructors Constructor Description OrdinalDomain()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Eget(int ordinal)Gets element from domain by corresponding ordinal value.java.util.Iterator<E>iterator()Iterator over all present inhabitants of ordinal domain.abstract intlength()Current length of ordinal domain.
-
-
-
Method Detail
-
get
public abstract E get(int ordinal)
Gets element from domain by corresponding ordinal value. It is guaranteed that returned element will haveOrdinalValue.ordinal()value equal to suppliedordinalparameter.- Parameters:
ordinal- ordinal value- Returns:
- the element by ordinal value
- Throws:
java.lang.IndexOutOfBoundsException- if no such element exists
-
length
public abstract int length()
Current length of ordinal domain. Be caution that length is not required to be stable and could grow, as such it could be used as a hint.- Returns:
- the domain length: current max ordinal value plus one
-
iterator
public java.util.Iterator<E> iterator()
Iterator over all present inhabitants of ordinal domain.- Specified by:
iteratorin interfacejava.lang.Iterable<E extends OrdinalValue<E>>- Returns:
- snapshot iterator of elements in ordinal domain.
-
-