Package | Description |
---|---|
com.google.inject |
Google Guice (pronounced "juice") is an ultra-lightweight dependency injection framework.
|
com.google.inject.binder |
Interfaces which make up
Binder 's expression language. |
com.google.inject.internal |
Guice (sounds like "juice")
|
com.google.inject.multibindings |
Extension for binding multiple instances in a collection; this extension requires
guice-multibindings.jar . |
com.google.inject.spi |
Guice service provider interface
|
Modifier and Type | Method and Description |
---|---|
static <T> TypeLiteral<T> |
TypeLiteral.get(Class<T> type)
Gets type literal for the given
Class instance. |
static TypeLiteral<?> |
TypeLiteral.get(Type type)
Gets type literal for the given
Type instance. |
TypeLiteral<?> |
TypeLiteral.getFieldType(Field field)
Returns the resolved generic type of
field . |
TypeLiteral<?> |
TypeLiteral.getReturnType(Method method)
Returns the resolved generic return type of
method . |
TypeLiteral<?> |
TypeLiteral.getSupertype(Class<?> supertype)
Returns the generic form of
supertype . |
TypeLiteral<T> |
Key.getTypeLiteral()
Gets the key type.
|
Modifier and Type | Method and Description |
---|---|
List<TypeLiteral<?>> |
TypeLiteral.getExceptionTypes(Member methodOrConstructor)
Returns the resolved generic exception types thrown by
constructor . |
List<TypeLiteral<?>> |
TypeLiteral.getParameterTypes(Member methodOrConstructor)
Returns the resolved generic parameter types of
methodOrConstructor . |
Modifier and Type | Method and Description |
---|---|
protected <T> AnnotatedBindingBuilder<T> |
AbstractModule.bind(TypeLiteral<T> typeLiteral) |
protected <T> AnnotatedBindingBuilder<T> |
PrivateModule.bind(TypeLiteral<T> typeLiteral) |
<T> AnnotatedBindingBuilder<T> |
Binder.bind(TypeLiteral<T> typeLiteral)
See the EDSL examples at
Binder . |
AnnotatedElementBuilder |
PrivateBinder.expose(TypeLiteral<?> type)
Makes a binding for
type available to the enclosing environment. |
protected AnnotatedElementBuilder |
PrivateModule.expose(TypeLiteral<?> type)
Makes a binding for
type available to other modules and the injector. |
<T> List<Binding<T>> |
Injector.findBindingsByType(TypeLiteral<T> type)
Returns all explicit bindings for
type . |
static <T> Key<T> |
Key.get(TypeLiteral<T> typeLiteral)
Gets a key for an injection type.
|
static <T> Key<T> |
Key.get(TypeLiteral<T> typeLiteral,
Annotation annotation)
Gets a key for an injection type and an annotation.
|
static <T> Key<T> |
Key.get(TypeLiteral<T> typeLiteral,
Class<? extends Annotation> annotationType)
Gets a key for an injection type and an annotation type.
|
<T> MembersInjector<T> |
Injector.getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
T . |
protected <T> MembersInjector<T> |
AbstractModule.getMembersInjector(TypeLiteral<T> type) |
protected <T> MembersInjector<T> |
PrivateModule.getMembersInjector(TypeLiteral<T> type) |
<T> MembersInjector<T> |
Binder.getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
T . |
<T> Key<T> |
Key.ofType(TypeLiteral<T> type)
Returns a new key of the specified type with the same annotation as this key.
|
<T> void |
Binder.requestInjection(TypeLiteral<T> type,
T instance)
Upon successful creation, the
Injector will inject instance fields and methods of the
given object. |
Modifier and Type | Method and Description |
---|---|
protected void |
AbstractModule.bindListener(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeListener listener) |
protected void |
PrivateModule.bindListener(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeListener listener) |
void |
Binder.bindListener(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeListener listener)
Registers a listener for injectable types.
|
protected void |
AbstractModule.convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter) |
protected void |
PrivateModule.convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter) |
void |
Binder.convertToTypes(Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter converter)
Binds a type converter.
|
Modifier and Type | Method and Description |
---|---|
ScopedBindingBuilder |
LinkedBindingBuilder.to(TypeLiteral<? extends T> implementation)
See the EDSL examples at
Binder . |
<S extends T> |
LinkedBindingBuilder.toConstructor(Constructor<S> constructor,
TypeLiteral<? extends S> type)
See the EDSL examples at
Binder . |
ScopedBindingBuilder |
LinkedBindingBuilder.toProvider(TypeLiteral<? extends javax.inject.Provider<? extends T>> providerType)
See the EDSL examples at
Binder . |
Modifier and Type | Method and Description |
---|---|
static <T> TypeLiteral<T> |
MoreTypes.canonicalizeForKey(TypeLiteral<T> typeLiteral)
Returns an type that's appropriate for use in a key.
|
Modifier and Type | Method and Description |
---|---|
Errors |
Errors.ambiguousTypeConversion(String stringValue,
Object source,
TypeLiteral<?> type,
TypeConverterBinding a,
TypeConverterBinding b) |
static <T> TypeLiteral<T> |
MoreTypes.canonicalizeForKey(TypeLiteral<T> typeLiteral)
Returns an type that's appropriate for use in a key.
|
Errors |
Errors.constructorNotDefinedByType(Constructor<?> constructor,
TypeLiteral<?> type) |
Errors |
Errors.conversionError(String stringValue,
Object source,
TypeLiteral<?> type,
TypeConverterBinding typeConverterBinding,
RuntimeException cause) |
Errors |
Errors.conversionTypeError(String stringValue,
Object source,
TypeLiteral<?> type,
TypeConverterBinding typeConverterBinding,
Object converted) |
Errors |
Errors.converterReturnedNull(String stringValue,
Object source,
TypeLiteral<?> type,
TypeConverterBinding typeConverterBinding) |
static InternalProvisionException |
InternalProvisionException.errorInUserInjector(MembersInjector<?> listener,
TypeLiteral<?> type,
RuntimeException cause) |
static InternalProvisionException |
InternalProvisionException.errorNotifyingInjectionListener(InjectionListener<?> listener,
TypeLiteral<?> type,
RuntimeException cause) |
Errors |
Errors.errorNotifyingTypeListener(TypeListenerBinding listener,
TypeLiteral<?> type,
Throwable cause) |
static Key<?> |
Annotations.getKey(TypeLiteral<?> type,
Member member,
Annotation[] annotations,
Errors errors)
Gets a key for the given type, member and annotations.
|
Errors |
Errors.keyNotFullySpecified(TypeLiteral<?> typeLiteral) |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newMapRealBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with no binding annotation. |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newMapRealBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with no binding annotation. |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newRealMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Annotation annotation)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotation . |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newRealMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Annotation annotation)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotation . |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newRealMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotationType . |
static <K,V> RealMapBinder<K,V> |
RealMapBinder.newRealMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotationType . |
BindingBuilder<T> |
BindingBuilder.to(TypeLiteral<? extends T> implementation) |
<S extends T> |
BindingBuilder.toConstructor(Constructor<S> constructor,
TypeLiteral<? extends S> type) |
BindingBuilder<T> |
BindingBuilder.toProvider(TypeLiteral<? extends javax.inject.Provider<? extends T>> providerType) |
Modifier and Type | Method and Description |
---|---|
TypeLiteral<?> |
MultibinderBinding.getElementTypeLiteral()
Returns the TypeLiteral that describes the type of elements in the set.
|
TypeLiteral<?> |
MapBinderBinding.getKeyTypeLiteral()
Returns the TypeLiteral describing the keys of the map.
|
TypeLiteral<?> |
MapBinderBinding.getValueTypeLiteral()
Returns the TypeLiteral describing the values of the map.
|
Modifier and Type | Method and Description |
---|---|
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with no binding annotation. |
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with no binding annotation. |
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Annotation annotation)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotation . |
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Annotation annotation)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotation . |
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotationType . |
static <K,V> MapBinder<K,V> |
MapBinder.newMapBinder(Binder binder,
TypeLiteral<K> keyType,
TypeLiteral<V> valueType,
Class<? extends Annotation> annotationType)
Returns a new mapbinder that collects entries of
keyType /valueType in a Map that is itself bound with annotationType . |
static <T> OptionalBinder<T> |
OptionalBinder.newOptionalBinder(Binder binder,
TypeLiteral<T> type) |
static <T> Multibinder<T> |
Multibinder.newSetBinder(Binder binder,
TypeLiteral<T> type)
Returns a new multibinder that collects instances of
type in a Set that is
itself bound with no binding annotation. |
static <T> Multibinder<T> |
Multibinder.newSetBinder(Binder binder,
TypeLiteral<T> type,
Annotation annotation)
Returns a new multibinder that collects instances of
type in a Set that is
itself bound with annotation . |
static <T> Multibinder<T> |
Multibinder.newSetBinder(Binder binder,
TypeLiteral<T> type,
Class<? extends Annotation> annotationType)
Returns a new multibinder that collects instances of
type in a Set that is
itself bound with annotationType . |
Modifier and Type | Method and Description |
---|---|
TypeLiteral<?> |
InjectionPoint.getDeclaringType()
Returns the generic type that defines this injection point.
|
TypeLiteral<T> |
InjectionRequest.getType() |
TypeLiteral<T> |
MembersInjectorLookup.getType()
Gets the type containing the members to be injected.
|
Modifier and Type | Method and Description |
---|---|
Matcher<? super TypeLiteral<?>> |
TypeListenerBinding.getTypeMatcher()
Returns the type matcher which chooses which types the listener should be notified of.
|
Matcher<? super TypeLiteral<?>> |
TypeConverterBinding.getTypeMatcher() |
Modifier and Type | Method and Description |
---|---|
Object |
TypeConverter.convert(String value,
TypeLiteral<?> toType)
Converts a string value.
|
static <T> InjectionPoint |
InjectionPoint.forConstructor(Constructor<T> constructor,
TypeLiteral<? extends T> type)
Returns a new injection point for the specified constructor of
type . |
static InjectionPoint |
InjectionPoint.forConstructorOf(TypeLiteral<?> type)
Returns a new injection point for the injectable constructor of
type . |
static Set<InjectionPoint> |
InjectionPoint.forInstanceMethodsAndFields(TypeLiteral<?> type)
Returns all instance method and field injection points on
type . |
static <T> InjectionPoint |
InjectionPoint.forMethod(Method method,
TypeLiteral<T> type)
Returns a new injection point for the specified method of
type . |
static Set<InjectionPoint> |
InjectionPoint.forStaticMethodsAndFields(TypeLiteral<?> type)
Returns all static method and field injection points on
type . |
<T> MembersInjector<T> |
TypeEncounter.getMembersInjector(TypeLiteral<T> typeLiteral)
Returns the members injector used to inject dependencies into methods and fields on instances
of the given type
T . |
<I> void |
TypeListener.hear(TypeLiteral<I> type,
TypeEncounter<I> encounter)
Invoked when Guice encounters a new type eligible for constructor or members injection.
|
Constructor and Description |
---|
InjectionRequest(Object source,
TypeLiteral<T> type,
T instance) |
MembersInjectorLookup(Object source,
TypeLiteral<T> type) |
Constructor and Description |
---|
TypeConverterBinding(Object source,
Matcher<? super TypeLiteral<?>> typeMatcher,
TypeConverter typeConverter) |
Copyright © 2006–2018 Google, Inc.. All rights reserved.