Interface IndexKeys
public sealed interface IndexKeys
Cached in tuples; each tuple carries its unique instance.
Instances are shallow immutable and implement Object.equals(Object) and Object.hashCode().
If two instances contain elements which are equal, they must be equal.
Instances should be obtained using none(),
of(Object),
of(Object, Object)
or ofMany(Object[]).
This interface only has two implementations,
giving the JVM simple bi-morphic call sites.
There is no NoIndexKeys, as that is handled by none().
There is also no SingleIndexKeys, see of(Object) for rationale.
TwoIndexKeys exists to avoid wrapping two keys with an entire array,
with the use case of two keys still being relatively common.
ThreeIndexKeys and higher are sufficiently rare for ManyIndexKeys to suffice.
-
Method Summary
-
Method Details
-
none
-
of
- Parameters:
key- may be null, typically in cases where the indexed property is a nullable planning variable.- Returns:
- When the key is not
null, returns the key itself, as opposed to some wrapping instance ofIndexKeys. Wrapping is not necessary in this case, as the wrapper would do nothing but delegateObject.equals(Object)andObject.hashCode()to the wrapped key anyway. Avoiding the wrapper saves considerable memory and gets rid of a level of indirection.
-
of
-
ofMany
-
get
<Key_> Key_ get(int id) Retrieves key at a given position.- Type Parameters:
Key_-ComparisonIndexerwill expect this to implementComparable.EqualsIndexerwill treat items as the same if they are equal.- Parameters:
id- Maps to a singleIndexerinstance in the indexer chain.- Returns:
- May be null if the key is null.
-