Interface InheritanceAwareMap<C,V>
- Type Parameters:
C- the base class typeV- the value type
public interface InheritanceAwareMap<C,V>
A map type that will traverse class hierarchy to find a value for a key.
These maps are null-hostile, so both keys and values must not be null.
There is a concept of strict mode, where map values have to be strictly non-ambiguous. When this enabled (by default it is not), a value will not be added if any subtypes or supertypes are already registered to the map.
Inheritance aware maps are always immutable, so any mutation operations will apply any changes to a new, modified instance.
- Since:
- 4.17.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic interfaceA builder for inheritance-aware maps. -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,E> InheritanceAwareMap.Builder <K, E> builder()Create a new builder for an inheritance aware map.static <K,E> InheritanceAwareMap.Builder <K, E> builder(InheritanceAwareMap<? extends K, ? extends E> existing) Create a new builder for an inheritance aware map.booleancontainsKey(Class<? extends C> clazz) Check whether this map contains a value (direct or computed) for the provided class.static <K,E> InheritanceAwareMap <K, E> empty()Get an empty inheritance aware map.@Nullable VGet the applicable value for the provided class.Get an updated inheritance aware map with the provided key changed.Get an updated inheritance aware map with the provided key removed.
-
Method Details
-
empty
Get an empty inheritance aware map.- Type Parameters:
K- class type upper boundE- value type- Returns:
- the map
- Since:
- 4.17.0
-
builder
Create a new builder for an inheritance aware map.- Type Parameters:
K- class type upper boundE- value type- Returns:
- a new builder
- Since:
- 4.17.0
-
builder
static <K,E> InheritanceAwareMap.Builder<K,E> builder(InheritanceAwareMap<? extends K, ? extends E> existing) Create a new builder for an inheritance aware map.- Type Parameters:
K- class type upper boundE- value type- Parameters:
existing- the existing map to populate the builder with- Returns:
- a new builder
- Since:
- 4.17.0
-
containsKey
-
get
-
with
-
without
Get an updated inheritance aware map with the provided key removed.- Parameters:
clazz- the class type to remove a direct value for- Returns:
- the updated map
- Since:
- 4.17.0
-