Class ClassToInstanceStore<T>
java.lang.Object
io.helidon.security.ClassToInstanceStore<T>
- Type Parameters:
T- Type all classes in this instance must extend
Map of classes to their instances.
This class is mutable and not thread safe.
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionbooleancontainsKey(Class<? extends T> clazz) Check if this store contains a mapping for a class.static <T> ClassToInstanceStore<T> create(T... instances) Create a new instance based on explicit instances.getInstance(Class<U> clazz) Get an instance from the store.booleanisEmpty()Check if this store is empty.Collection<Class<? extends T>> keys()Get all keys of this store.voidputAll(ClassToInstanceStore<? extends T> toCopy) Put all mappings from another instance.putInstance(Class<? extends U> clazz, U instance) Put an explicit class to instance mapping.putInstance(U instance) Put an instance with implicit class mapping into this store.removeInstance(Class<U> clazz) Remove an instance from the store and return current value.toString()Returns the toString on underlying map.values()Get all values of this store.
-
Constructor Details
-
ClassToInstanceStore
Deprecated, for removal: This API element is subject to removal in a future version.Usecreate(Object...)instead.Create an empty mutable class-to-instance store.
-
-
Method Details
-
create
Create a new instance based on explicit instances. This method creates a MUTABLE instance (contrary to such methods on java collections).- Type Parameters:
T- type of the store- Parameters:
instances- instances to add to the new store- Returns:
- new store with instances inserted as when calling
putInstance(Object)for each of them
-
getInstance
Get an instance from the store.- Type Parameters:
U- Type we are expecting- Parameters:
clazz- Class under which we have created the mapping (String and CharSequence are two distinct mappings!)- Returns:
- Instance of the class or null if no mapping exists
-
putInstance
Put an explicit class to instance mapping.- Type Parameters:
U- Type we are expecting- Parameters:
clazz- Class for which to create a mapping (String and CharSequence create two distinct mappings!)instance- Instance of the interface/class- Returns:
- Instance of the class if a mapping previously existed or null for no existing mapping
-
removeInstance
-
putAll
Put all mappings from another instance.- Parameters:
toCopy- store to copy into this store
-
containsKey
-
isEmpty
public boolean isEmpty()Check if this store is empty.- Returns:
- true if there are no mappings in this store
-
putInstance
Put an instance with implicit class mapping into this store. Please useputInstance(Class, Object)when feasible as it provides more explicit mapping. This is a helper method for instances obtained by other means or where we are sure of the class of the instance.- Type Parameters:
U- Type of this instance- Parameters:
instance- instance to map to its class (obtained throughObject.getClass()- Returns:
- existing value for the class of this instance
-
values
-
keys
Get all keys of this store.- Returns:
- collection of classes used for mapping to instances
-
toString
-
create(Object...)instead.