-
Notifications
You must be signed in to change notification settings - Fork 0
Home
pie-ai edited this page Oct 24, 2016
·
2 revisions
This is our common used very slim API based configuration library.
Examples can be found at https://github.com/pie-ai/pa-commons-configuration/tree/master/src/test/java/de/pa2/commons/configuration/examples
public interface ExampleConfiguration extends Configuration {
@DefaultBooleanValue(true)
boolean isEnabledByDefault();
@DefaultBooleanValue(false)
boolean isNotEnabledByDefault();
boolean isNotDefaultAnnotated();
}ExampleConfiguration cfg = ConfigurationFactory.getInstance(ExampleConfiguration.class);
assertThat(cfg.isEnabledByDefault()).isTrue();System.setProperty("example.enabled.by.default", Boolean.FALSE.toString());
ExampleConfiguration cfg = ConfigurationFactory.getInstance(ExampleConfiguration.class);
assertThat(cfg.isEnabledByDefault()).isFalse();Map<String, String> configuration = new HashMap<String, String>();
configuration.put("example.enabled.by.default", Boolean.FALSE.toString());
ExampleConfiguration cfg = ConfigurationFactory.getInstance(ExampleConfiguration.class, configuration);
assertThat(cfg.isEnabledByDefault()).isFalse();