Package org.int4.dirk.core.store
Class QualifiedTypeStore<T>
- java.lang.Object
-
- org.int4.dirk.core.store.QualifiedTypeStore<T>
-
-
Constructor Summary
Constructors Constructor Description QualifiedTypeStore(java.util.function.Function<T,Key> keyExtractor, java.util.function.Function<T,java.util.Set<java.lang.reflect.Type>> typesExtractor)Constructs a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontains(Key key)Checks if there is a typeTassociated with the givenKeyin the store.voidput(T qualifiedType)Adds a typeTto the store.voidputAll(java.util.Collection<T> qualifiedTypes)Adds multiple typeTs to the store.voidremove(T qualifiedType)Removes a typeTfrom the store.voidremoveAll(java.util.Collection<T> qualifiedTypes)Removes multiple typeTs from the store.java.util.Set<T>resolve(Key key)Look up typesTbyKey.java.util.Set<T>toSet()Returns a set with a copy of all typeTs that are part of this store.<U> UtoSet(java.util.function.Function<java.util.stream.Stream<T>,U> function)Applies a function over all typeTs that are part of this store.java.lang.StringtoString()
-
-
-
Constructor Detail
-
QualifiedTypeStore
public QualifiedTypeStore(java.util.function.Function<T,Key> keyExtractor, java.util.function.Function<T,java.util.Set<java.lang.reflect.Type>> typesExtractor)
Constructs a new instance.- Parameters:
keyExtractor- aFunctionto extract aKeyfrom a typeT, cannot benulltypesExtractor- aFunctionto extract a set ofTypefrom a typeT, cannot benull
-
-
Method Detail
-
resolve
public java.util.Set<T> resolve(Key key)
Description copied from interface:ResolverLook up typesTbyKey. The empty set is returned if there were no matches.
-
contains
public boolean contains(Key key)
Checks if there is a typeTassociated with the givenKeyin the store.
-
put
public void put(T qualifiedType) throws org.int4.dirk.api.definition.DuplicateDependencyException
Adds a typeTto the store.- Parameters:
qualifiedType- a typeT, cannot benull- Throws:
org.int4.dirk.api.definition.DuplicateDependencyException- when a dependency was already present in the store
-
remove
public void remove(T qualifiedType) throws org.int4.dirk.api.definition.MissingDependencyException
Removes a typeTfrom the store.- Parameters:
qualifiedType- a typeT, cannot benull- Throws:
org.int4.dirk.api.definition.MissingDependencyException- when a dependency was not present in the store
-
putAll
public void putAll(java.util.Collection<T> qualifiedTypes) throws org.int4.dirk.api.definition.DuplicateDependencyException
Adds multiple typeTs to the store. If this method throws an exception then the store will be unmodified.- Parameters:
qualifiedTypes- a collection of typeTs, cannot benullor containnulls but can be empty- Throws:
org.int4.dirk.api.definition.DuplicateDependencyException- when a dependency was already present in the store
-
removeAll
public void removeAll(java.util.Collection<T> qualifiedTypes) throws org.int4.dirk.api.definition.MissingDependencyException
Removes multiple typeTs from the store. If this method throws an exception then the store will be unmodified.- Parameters:
qualifiedTypes- a collection of typeTs, cannot benullor containnulls but can be empty- Throws:
org.int4.dirk.api.definition.MissingDependencyException- when a dependency was not present in the store
-
toSet
public java.util.Set<T> toSet()
Returns a set with a copy of all typeTs that are part of this store.- Returns:
- a set with a copy of all type
Ts that are part of this store, nevernullor containsnulls but can be empty
-
toSet
public <U> U toSet(java.util.function.Function<java.util.stream.Stream<T>,U> function)
Applies a function over all typeTs that are part of this store.Note: this call is expensive as the stream contains all types in the store. Furthermore, the function provided must call a terminating operation on the stream to avoid unsynchronized access to the stores internal structures.
Useful for debugging purposes and providing helpful exception messages.
- Type Parameters:
U- the function result type- Parameters:
function- aFunctionto apply, cannot benull- Returns:
- the result of applying the given function, can be
null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-