A strongly-typed, immutable, simple alternative to Properties or Map<String, Object>
cd3f5244a5
Bumps assertj-core from 3.19.0 to 3.24.2. --- updated-dependencies: - dependency-name: org.assertj:assertj-core dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> |
||
---|---|---|
.github | ||
src | ||
pom.xml | ||
README.md |
TypedProperties
A strongly-typed, immutable, simple alternative to Properties
or, sanity-save-you, Map<String, Object>
.
Usage
import net.kemitix.properties.typed.TypedProperties;
import net.kemitix.properties.typed.TypedProperty;
class Usage {
public static void main(String[] args){
// Create a new instance
TypedProperties properties = TypedProperties.create();
// Set a value - creates a new instance - immutability
// parameters: key, value
// - key is a class/interface, that extends TypedProperty<T>,
// where T is the type of the value.
// - value is of type T
TypedProperties updated = properties.with(Name.class, "Name");
// Retrieve a value
// parameters: key, value-type
// - key is same as above
// - value-type is the type of the value - must match key
Optional<String> result = updated.find(Name.class, String.class);
}
}
public interface Name
extends TypedProperty<String> {}