Package org.eclipse.sisu.inject
Class InjectorBindings
- java.lang.Object
-
- org.eclipse.sisu.inject.InjectorBindings
-
- All Implemented Interfaces:
BindingPublisher
public final class InjectorBindings extends java.lang.Object implements BindingPublisher
-
-
Field Summary
Fields Modifier and Type Field Description private static com.google.inject.Key<BindingPublisher>BINDING_PUBLISHER_KEYprivate static RankingFunctionDEFAULT_RANKING_FUNCTIONprivate RankingFunctionfunctionprivate com.google.inject.Injectorinjectorprivate static com.google.inject.Binding<?>[]NO_BINDINGSprivate static com.google.inject.TypeLiteral<java.lang.Object>OBJECT_TYPE_LITERALprivate static com.google.inject.Key<RankingFunction>RANKING_FUNCTION_KEYprivate com.google.inject.Binding<?>[]wildcards
-
Constructor Summary
Constructors Constructor Description InjectorBindings(com.google.inject.Injector injector)InjectorBindings(com.google.inject.Injector injector, RankingFunction function)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> Tadapt(java.lang.Class<T> type)Attempts to adapt this publisher to the given type.booleanequals(java.lang.Object rhs)static BindingPublisherfindBindingPublisher(com.google.inject.Injector injector)private static <T> com.google.inject.Binding<T>findExplicitBinding(com.google.inject.Injector injector, com.google.inject.Key<T> key)SearchesInjectorand its parents for an explicit binding of the givenKey.static RankingFunctionfindRankingFunction(com.google.inject.Injector injector)private com.google.inject.Binding<?>[]getWildcardBindings()inthashCode()private static <T,S>
booleanisAssignableFrom(com.google.inject.TypeLiteral<T> type, com.google.inject.Binding<S> binding)intmaxBindingRank()Estimates the maximum rank this publisher may assign to aBinding.private <T> voidpublishExactMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber)private <T,S>
voidpublishGenericMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber, java.lang.Class<S> rawType)private <T> voidpublishWildcardMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber)<T> voidsubscribe(BindingSubscriber<T> subscriber)Subscribes the givenBindingSubscriberto receiveBindings.java.lang.StringtoString()<T> voidunsubscribe(BindingSubscriber<T> subscriber)Stops the givenBindingSubscriberfrom receivingBindings.
-
-
-
Field Detail
-
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<java.lang.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 Detail
-
InjectorBindings
public InjectorBindings(com.google.inject.Injector injector, RankingFunction function)
-
InjectorBindings
@Inject public InjectorBindings(com.google.inject.Injector injector)
-
-
Method Detail
-
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:BindingPublisherSubscribes the givenBindingSubscriberto receiveBindings.- Specified by:
subscribein interfaceBindingPublisher- Parameters:
subscriber- The subscriber
-
unsubscribe
public <T> void unsubscribe(BindingSubscriber<T> subscriber)
Description copied from interface:BindingPublisherStops the givenBindingSubscriberfrom receivingBindings.- Specified by:
unsubscribein interfaceBindingPublisher- Parameters:
subscriber- The subscriber
-
maxBindingRank
public int maxBindingRank()
Description copied from interface:BindingPublisherEstimates the maximum rank this publisher may assign to aBinding.- Specified by:
maxBindingRankin interfaceBindingPublisher- Returns:
- Maximum binding rank
-
adapt
public <T> T adapt(java.lang.Class<T> type)
Description copied from interface:BindingPublisherAttempts to adapt this publisher to the given type.- Specified by:
adaptin interfaceBindingPublisher- Parameters:
type- The target type- Returns:
- Adapted instance;
nullif it couldn't be adapted
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object rhs)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
findExplicitBinding
private static <T> com.google.inject.Binding<T> findExplicitBinding(com.google.inject.Injector injector, com.google.inject.Key<T> key)SearchesInjectorand its parents for an explicit binding of the givenKey.- Parameters:
injector- The injectorkey- The binding key- Returns:
- Explicit binding of the key;
nullif 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, java.lang.Class<S> rawType)
-
publishWildcardMatches
private <T> void publishWildcardMatches(com.google.inject.TypeLiteral<T> type, BindingSubscriber<T> subscriber)
-
getWildcardBindings
private com.google.inject.Binding<?>[] getWildcardBindings()
-
-