Skip to content

pie-ai/pa-commons-configuration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

de.pa2.commons-configuration

This is our common used very slim API based configuration library.

usage

Examples can be found at https://github.com/pie-ai/pa-commons-configuration/tree/master/src/test/java/de/pa2/commons/configuration

Create a configuration interface:

public interface ExampleConfiguration extends Configuration {
	@DefaultBooleanValue(true)
	boolean isEnabledByDefault();

	@DefaultBooleanValue(false)
	boolean isNotEnabledByDefault();

	boolean isNotDefaultAnnotated();
}

Get an instance:

ExampleConfiguration cfg = ConfigurationFactory.getInstance(ExampleConfiguration.class);
assertThat(cfg.isEnabledByDefault()).isTrue();

Override configuration using System Properties:

System.setProperty("example.enabled.by.default", Boolean.FALSE.toString());
ExampleConfiguration cfg = ConfigurationFactory.getInstance(ExampleConfiguration.class);
assertThat(cfg.isEnabledByDefault()).isFalse();

Override configuration using Map:

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();

About

simple java configuration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages