Settings API

Core implementation and interfaces for defining context-specific settings

License

License

GroupId

GroupId

com.github.nordstrom.tools
ArtifactId

ArtifactId

settings
Last Version

Last Version

2.0.6
Release Date

Release Date

Type

Type

jar
Description

Description

Settings API
Core implementation and interfaces for defining context-specific settings
Project URL

Project URL

https://github.com/Nordstrom/Settings
Source Code Management

Source Code Management

https://github.com/Nordstrom/Settings/tree/master

Download settings

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.nordstrom.tools/settings/ -->
<dependency>
    <groupId>com.github.nordstrom.tools</groupId>
    <artifactId>settings</artifactId>
    <version>2.0.6</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.nordstrom.tools/settings/
implementation 'com.github.nordstrom.tools:settings:2.0.6'
// https://jarcasting.com/artifacts/com.github.nordstrom.tools/settings/
implementation ("com.github.nordstrom.tools:settings:2.0.6")
'com.github.nordstrom.tools:settings:jar:2.0.6'
<dependency org="com.github.nordstrom.tools" name="settings" rev="2.0.6">
  <artifact name="settings" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.nordstrom.tools', module='settings', version='2.0.6')
)
libraryDependencies += "com.github.nordstrom.tools" % "settings" % "2.0.6"
[com.github.nordstrom.tools/settings "2.0.6"]

Dependencies

compile (7)

Group / Artifact Type Version
ch.qos.logback : logback-classic jar 1.2.2
ch.qos.logback : logback-core jar 1.2.2
org.slf4j : slf4j-api jar 1.7.25
com.github.nordstrom.tools : java-utils jar 1.3.1
org.apache.commons : commons-lang3 jar 3.5
org.apache.commons : commons-configuration2 jar 2.1.1
commons-beanutils : commons-beanutils jar 1.9.3

test (1)

Group / Artifact Type Version
org.testng : testng jar 6.10

Project Modules

There are no modules declared in this project.

Maven Central

SettingsCore

Composition of configurations

The SettingsCore class extends CompositeConfiguration, using the facilities provided by this class to produce an aggregated configuration from three sources in the following order of precedence:

  1. System properties
  2. (optional) Stored properties, typically from a properties file
  3. (optional) Default values, typically specified in the enumeration

Declaring stored properties

To specify stored properties for your configuration, override one of following methods:

  • getStoredConfig - Your implementation returns a populated Configuration object.
  • getInputStream - Your implementation returns an input stream supplying key/value pairs.
  • getSettingsUrl - Your implementation returns the URL from which to load your settings.
  • getSettingsPath - Your implementation returns the path from which to load your settings.

NOTE: These methods are listed in order of evaluation, which stops at the first non-null response.
NOTE: Typical implementations override getSettingsPath, which will support most scenarios.
NOTE: Stored properties are declared in Apache's extended syntax. See PropertiesConfiguration for details.
NOTE: By overriding the getStoredConfig method, you're able to incorporate any arbitrary Configuration object you need into your settings - including another CompositeConfiguration object.

Specifying default values

Two methods have been provided for you to supply default values for your configuration:

  • Specify default values as arguments of the constant declarations in your settings enumeration and override the SettingsAPI.val method. Specifying 'null' for a setting's default value indicates that no default exists.
  • Alternatively, you can override the getDefaults method with your own implementation.

NOTE: For settings collections with no default values, you can eliminate unnecessary processing in the core API by overriding getDefaults with a method that simply returns 'null'.

Declaring configuration settings

Implementations of SettingsCore supply a context-specific enumeration (which extends Enum<T>) to provide the collection of settings needed in this context. This enumeration must implement the SettingsAPI interface to provide clients with a common method for retrieving configuration keys and to give the core settings implementation access to the constants and default values of the enumeration.

Configuration examples

For example implementations of SettingsCore, check out this project's units tests. These demonstrate all of the major features of the API, including:

  • Declaration of settings and default values
  • Declaration and formatting of backing files
  • Extraction of typed data
  • Declaration of lists of values
  • Overrides of stored and default values
  • Configurable inclusion of sub-configurations
com.github.nordstrom.tools

Nordstrom, Inc.

Nordstrom, Inc. is a specialty fashion retailer, headquartered in Seattle, Washington

Versions

Version
2.0.6
2.0.5