Package io.activej.inject.binding
Class Multibinders
java.lang.Object
io.activej.inject.binding.Multibinders
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Multibinder<?>combinedMultibinder(Map<Key<?>, Multibinder<?>> multibinders) Combines all multibinders into one by their type and returns universal multibinder for any key from the map, falling back toerrorOnDuplicate()when map contains no multibinder for a given key.static <T> Multibinder<T>Default multibinder that just throws an exception if there is more than one binding per key.static <T> Multibinder<T>ofBinaryOperator(BinaryOperator<T> binaryOperator) Multibinder that returns a binding that reduces all instances provided by all conflicting bindings using a binary operator.static <T> Multibinder<T>ofReducer(BiFunction<Key<T>, Stream<T>, T> reducerFunction) Multibinder that returns a binding that applies given reducing function to a stream of instances provided by all conflicting bindings.static <K,V> Multibinder<Map<K, V>> toMap()Multibinder that returns a binding for a merged map of maps provided by all conflicting bindings.static <T> Multibinder<Set<T>>toSet()Multibinder that returns a binding for a merged set of sets provided by all conflicting bindings.
-
Constructor Details
-
Multibinders
public Multibinders()
-
-
Method Details
-
errorOnDuplicate
Default multibinder that just throws an exception if there is more than one binding per key. -
ofReducer
Multibinder that returns a binding that applies given reducing function to a stream of instances provided by all conflicting bindings. -
ofBinaryOperator
Multibinder that returns a binding that reduces all instances provided by all conflicting bindings using a binary operator. -
toSet
Multibinder that returns a binding for a merged set of sets provided by all conflicting bindings. -
toMap
Multibinder that returns a binding for a merged map of maps provided by all conflicting bindings.- Throws:
DIException- on map merge conflicts
-
combinedMultibinder
Combines all multibinders into one by their type and returns universal multibinder for any key from the map, falling back toerrorOnDuplicate()when map contains no multibinder for a given key.
-