A strongly-typed, immutable, simple alternative to Properties or Map<String, Object>
b2c37f77e2
* Bump tiles-maven-plugin from 2.17 to 2.18 Bumps [tiles-maven-plugin](https://github.com/repaint-io/maven-tiles) from 2.17 to 2.18. - [Release notes](https://github.com/repaint-io/maven-tiles/releases) - [Changelog](https://github.com/repaint-io/maven-tiles/blob/master/CHANGELOG.adoc) - [Commits](https://github.com/repaint-io/maven-tiles/compare/tiles-maven-plugin-2.17...tiles-maven-plugin-2.18) Signed-off-by: dependabot-preview[bot] <support@dependabot.com> * Test build with JDK 15 Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Paul Campbell <pcampbell@kemitix.net> |
||
---|---|---|
.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> {}