Annotation Type Config
-
@Target({TYPE,METHOD,FIELD,PARAMETER}) @Retention(RUNTIME) public @interface Config
Guice qualifier annotation for configuration values binding. Could be used to bind:- Configuration object itself by any class or interface:
@Inject @Config Configuration config
(note that root configuration classes may be used without qualifier also for compatibility) - Unique configuration sub objects:
@Inject @Config SubConfiguration sub
- Configuration value by path (yaml):
@Inject @Config("property.path") String value
. Value type must match property declaration type (including generics).
Generics are mostly useful for collection classes:
@Inject @Config("some.path) List<String> values;
. Binding without generic is impossible (you must use all available type information).Note that only properties visible for writing are present: properties which jackson could read. Even dropwizard gude contains examples when configuration setter did not store value and use it immediately to create some other objects. Obviously such properties are impossible to "read back" and so impossible to bind.
Property visibility may also be affected by annotated getter absence: for example, suppose there are no getters and
@JsonProperty private String foo
,private String bar
then only annotated "foo" property would be visible. When property getter is present - property will be found, even without annotations.- Since:
- 04.05.2018
- See Also:
for available bindings
- Configuration object itself by any class or interface:
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description java.lang.String
value
-