@Documented @Target(value=ANNOTATION_TYPE) @Retention(value=RUNTIME) public @interface MapKey
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.Modifier and Type | Optional Element and Description |
---|---|
boolean |
unwrapValue
if
unwrapValue is false, then the whole annotation will be the type and annotation
instances will be the keys. |
public abstract boolean unwrapValue
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.Copyright © 2006–2018 Google, Inc.. All rights reserved.