Class Multibinders

java.lang.Object
io.activej.inject.binding.Multibinders

public final class Multibinders extends Object
  • Constructor Details

    • Multibinders

      public Multibinders()
  • Method Details

    • errorOnDuplicate

      public static <T> Multibinder<T> errorOnDuplicate()
      Default multibinder that just throws an exception if there is more than one binding per key.
    • ofReducer

      public 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.
    • ofBinaryOperator

      public 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.
      See Also:
    • toSet

      public static <T> Multibinder<Set<T>> toSet()
      Multibinder that returns a binding for a merged set of sets provided by all conflicting bindings.
    • toMap

      public static <K, V> Multibinder<Map<K,V>> toMap()
      Multibinder that returns a binding for a merged map of maps provided by all conflicting bindings.
      Throws:
      DIException - on map merge conflicts
    • combinedMultibinder

      public static 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 to errorOnDuplicate() when map contains no multibinder for a given key.