Package de.scravy.bedrock
Interface Mapping<From,To>
- Type Parameters:
From- The type of the keys.To- The type of the values.
- All Superinterfaces:
ExtendedIterable<Pair<From,To>>,Function<From,To>,Function1<From,To>,HasLengthAtLeast,Iterable<Pair<From,To>>
- All Known Implementing Classes:
ArrayMap,Mapping.EmptyMapping
public interface Mapping<From,To> extends Function1<From,To>, ExtendedIterable<Pair<From,To>>
A Mapping from keys to values. A Mapping is very much like
Map, but it precludes mutable operations.
Every mapping is a function from keys to values that does know about the keys it maps. Hence a minimal
complete definition of a Mapping consists of get(Object) and keys().
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMapping.EmptyMapping<K,V>Nested classes/interfaces inherited from interface de.scravy.bedrock.ExtendedIterable
ExtendedIterable.ForEachWithIndexConsumer<T> -
Method Summary
Modifier and Type Method Description default Toapply(From key)static <K, V> Mapping<K,V>empty()default voidforEach(BiConsumer<? super From,? super To> action)Optional<To>get(From key)Retrieves the value associated with the given key or Optional.empty() if the key is not mapped to any value.default TogetOrElse(From key, To fallback)default TogetOrNull(From key)default booleanisEmpty()default Iterator<Pair<From,To>>iterator()Seq<From>keys()default intsize()default Stream<Pair<From,To>>stream()default Map<From,To>toMap()default Seq<To>values()static <From, To> Mapping<From,To>wrap(Map<From,To> map)
-
Method Details
-
get
Retrieves the value associated with the given key or Optional.empty() if the key is not mapped to any value.- Parameters:
key- The key.- Returns:
- The value which the given key is mapped to.
-
keys
-
getOrElse
-
getOrNull
-
apply
-
size
default int size() -
isEmpty
default boolean isEmpty() -
values
-
iterator
-
stream
-
toMap
-
forEach
-
wrap
-
empty
-