Package com.google.inject.multibindings
Annotation Type MapKey
-
@Documented @Target(ANNOTATION_TYPE) @Retention(RUNTIME) public @interface MapKey
Allows users define customized key type annotations for map bindings by annotating an annotation of aMap's key type. The custom key annotation can be applied to methods also annotated with @ProvidesIntoMap.A
StringMapKeyandClassMapKeyare 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, ifunwrapValue=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. IfunwrapValue=true, the value() type will be the key type for injected map and the value() instances will be the keys values.- Since:
- 4.0
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleanunwrapValueifunwrapValueis false, then the whole annotation will be the type and annotation instances will be the keys.
-
-
-
Element Detail
-
unwrapValue
boolean unwrapValue
ifunwrapValueis false, then the whole annotation will be the type and annotation instances will be the keys. IfunwrapValueis true, the value() type of key type annotation will be the key type for injected map and the value instances will be the keys.- Default:
- true
-
-