Class QualifiedTypeBinder

java.lang.Object
org.eclipse.sisu.space.QualifiedTypeBinder
All Implemented Interfaces:
QualifiedTypeListener

public final class QualifiedTypeBinder extends Object implements QualifiedTypeListener
QualifiedTypeListener that installs Modules, registers Mediators, and binds types.
  • Field Details

    • OBJECT_TYPE_LITERAL

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

      private static final boolean HAS_JSR299_TYPED
    • rootBinder

      private final com.google.inject.Binder rootBinder
    • mediationListener

      private MediationListener mediationListener
    • currentSource

      private Object currentSource
    • binder

      private com.google.inject.Binder binder
  • Constructor Details

    • QualifiedTypeBinder

      public QualifiedTypeBinder(com.google.inject.Binder binder)
  • Method Details

    • hear

      public void hear(Class qualifiedType, Object source)
      Description copied from interface: QualifiedTypeListener
      Invoked when the QualifiedTypeVisitor finds a qualified type.
      Specified by:
      hear in interface QualifiedTypeListener
      Parameters:
      qualifiedType - The qualified type
      source - The source of this type
      See Also:
      • Binder.withSource(Object)
    • installModule

      private void installModule(Class<com.google.inject.Module> moduleType)
      Installs an instance of the given Module.
      Parameters:
      moduleType - The module type
    • registerMediator

      private void registerMediator(Class<Mediator> mediatorType)
      Registers an instance of the given Mediator using its generic type arguments as configuration.
      Parameters:
      mediatorType - The mediator type
    • registerLegacyMediator

      private void registerLegacyMediator(Class<Mediator> mediatorType)
    • mediate

      private void mediate(com.google.inject.Key watchedKey, Mediator mediator, Class watcherType)
      Uses the given mediator to mediate updates between the BeanLocator and associated watchers.
      Parameters:
      watchedKey - The watched key
      mediator - The bean mediator
      watcherType - The watcher type
    • bindProviderType

      private void bindProviderType(Class<?> providerType)
      Binds the given provider type using a binding key determined by common-use heuristics.
      Parameters:
      providerType - The provider type
    • bindQualifiedType

      private void bindQualifiedType(Class<?> qualifiedType)
      Binds the given qualified type using a binding key determined by common-use heuristics.
      Parameters:
      qualifiedType - The qualified type
    • newInstance

      private <T> T newInstance(Class<T> type)
      Attempts to create a new instance of the given type.
      Parameters:
      type - The instance type
      Returns:
      New instance; null if the instance couldn't be created
    • resolveTypeArguments

      private static com.google.inject.TypeLiteral<?>[] resolveTypeArguments(Class<?> type, Class<?> superType)
      Resolves the type arguments of a super type based on the given concrete type.
      Parameters:
      type - The concrete type
      superType - The generic super type
      Returns:
      Resolved super type arguments
    • getBindingKey

      private static <T> com.google.inject.Key<T> getBindingKey(com.google.inject.TypeLiteral<T> bindingType, Annotation qualifier)
    • getBindingName

      private static com.google.inject.name.Named getBindingName(Class<?> qualifiedType)
    • getBindingTypes

      private static Class<?>[] getBindingTypes(Class<?> clazz)
    • isSingleton

      private static boolean isSingleton(Class<?> type)
    • isEagerSingleton

      private static boolean isEagerSingleton(Class<?> type)
    • watchedKey

      private static <T> com.google.inject.Key<T> watchedKey(com.google.inject.TypeLiteral<T> type, Class qualifierType)