Top Description Methods
com.google.inject.multibindings

public @Interface MapKey

extends Annotation
Annotations
@Documented
@Target:ANNOTATION_TYPE
@Retention:RUNTIME
Static Imports
java.lang.annotation.ElementType.ANNOTATION_TYPE, .RetentionPolicy.RUNTIME

Allows users define customized key type annotations for map bindings by annotating an annotation of a Map's key type. The custom key annotation can be applied to methods also annotated with @ProvidesIntoMap.

A StringMapKey and ClassMapKey are provided for convenience with maps whose keys are strings or classes. For maps with enums or primitive types as keys, you must provide your own MapKey annotation, such as this one for an enum:

@MapKey(unwrapValue = true)
@Retention(RUNTIME)
public @interface MyCustomEnumKey {
  MyCustomEnum value();
}
You can also use the whole annotation as the key, if unwrapValue=false. When unwrapValue is false, the annotation type will be the key type for the injected map and the annotation instances will be the key values. If unwrapValue=true, the value() type will be the key type for injected map and the value() instances will be the keys values.
Since
4.0

Method Summary

Modifier and TypeMethod and Description
public boolean
unwrapValue()

if unwrapValue is false, then the whole annotation will be the type and annotation instances will be the keys.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

unwrapValueback to summary
public boolean unwrapValue()

if unwrapValue is false, then the whole annotation will be the type and annotation instances will be the keys. If unwrapValue is true, the value() type of key type annotation will be the key type for injected map and the value instances will be the keys.