Class InjectorBindings

java.lang.Object
org.eclipse.sisu.inject.InjectorBindings
All Implemented Interfaces:
BindingPublisher

public final class InjectorBindings extends Object implements BindingPublisher
Publisher of Bindings from a single Injector; ranked according to a given RankingFunction.
  • Field Details

    • BINDING_PUBLISHER_KEY

      private static final com.google.inject.Key<BindingPublisher> BINDING_PUBLISHER_KEY
    • RANKING_FUNCTION_KEY

      private static final com.google.inject.Key<RankingFunction> RANKING_FUNCTION_KEY
    • DEFAULT_RANKING_FUNCTION

      private static final RankingFunction DEFAULT_RANKING_FUNCTION
    • OBJECT_TYPE_LITERAL

      private static final com.google.inject.TypeLiteral<Object> OBJECT_TYPE_LITERAL
    • NO_BINDINGS

      private static final com.google.inject.Binding<?>[] NO_BINDINGS
    • injector

      private final com.google.inject.Injector injector
    • function

      private final RankingFunction function
    • wildcards

      private volatile com.google.inject.Binding<?>[] wildcards
  • Constructor Details

    • InjectorBindings

      public InjectorBindings(com.google.inject.Injector injector, RankingFunction function)
    • InjectorBindings

      @Inject public InjectorBindings(com.google.inject.Injector injector)
  • Method Details

    • findBindingPublisher

      public static BindingPublisher findBindingPublisher(com.google.inject.Injector injector)
    • findRankingFunction

      public static RankingFunction findRankingFunction(com.google.inject.Injector injector)
    • subscribe

      public <T> void subscribe(BindingSubscriber<T> subscriber)
      Description copied from interface: BindingPublisher
      Subscribes the given BindingSubscriber to receive Bindings.
      Specified by:
      subscribe in interface BindingPublisher
      Parameters:
      subscriber - The subscriber
    • unsubscribe

      public <T> void unsubscribe(BindingSubscriber<T> subscriber)
      Description copied from interface: BindingPublisher
      Stops the given BindingSubscriber from receiving Bindings.
      Specified by:
      unsubscribe in interface BindingPublisher
      Parameters:
      subscriber - The subscriber
    • maxBindingRank

      public int maxBindingRank()
      Description copied from interface: BindingPublisher
      Estimates the maximum rank this publisher may assign to a Binding.
      Specified by:
      maxBindingRank in interface BindingPublisher
      Returns:
      Maximum binding rank
    • adapt

      public <T> T adapt(Class<T> type)
      Description copied from interface: BindingPublisher
      Attempts to adapt this publisher to the given type.
      Specified by:
      adapt in interface BindingPublisher
      Parameters:
      type - The target type
      Returns:
      Adapted instance; null if it couldn't be adapted
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object rhs)
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • findExplicitBinding

      private static <T> com.google.inject.Binding<T> findExplicitBinding(com.google.inject.Injector injector, com.google.inject.Key<T> key)
      Searches Injector and its parents for an explicit binding of the given Key.
      Parameters:
      injector - The injector
      key - The binding key
      Returns:
      Explicit binding of the key; null if it doesn't exist
    • isAssignableFrom

      private static <T, S> boolean isAssignableFrom(com.google.inject.TypeLiteral<T> type, com.google.inject.Binding<S> binding)
    • publishExactMatches

      private <T> void publishExactMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber)
    • publishGenericMatches

      private <T, S> void publishGenericMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber, Class<S> rawType)
    • publishWildcardMatches

      private <T> void publishWildcardMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber)
    • getWildcardBindings

      private com.google.inject.Binding<?>[] getWildcardBindings()