public interface Position extends Comparable<Position>
Modifier and Type | Method and Description |
---|---|
Index |
asIndex()
Casts this position into an Index, throwing an exception if it's a Key.
|
Key |
asKey()
Casts this position into a Key, throwing an exception if it's an index.
|
boolean |
isIndex()
Returns true if this position is an index.
|
default boolean |
isIndex(IntPredicate predicate)
Returns true if this position is an index and its index tested on a given predicate is true.
|
boolean |
isKey()
Returns true if this position is an key.
|
default boolean |
isKey(Predicate<String> predicate)
Returns true if this position is a key and its name tested on a given predicate is true.
|
default <T> T |
match(Function<String,T> keyFn,
IntFunction<T> indexFn)
Returns a new value applying pattern matching on the Position type.
|
compareTo
default boolean isKey(Predicate<String> predicate)
predicate
- the give predicateboolean isIndex()
Key asKey()
UserError
- if this position is an Indexdefault boolean isIndex(IntPredicate predicate)
predicate
- the give predicateboolean isKey()
Index asIndex()
UserError
- if this position is an Keydefault <T> T match(Function<String,T> keyFn, IntFunction<T> indexFn)
T
- the type of the object returnedkeyFn
- function to apply if this Position is a keyindexFn
- function to apply if this Position is an indexCopyright © 2022. All rights reserved.