Package com.complexible.common.base
Class PropertiesBuilder
java.lang.Object
com.complexible.common.base.PropertiesBuilder
Simple builder class for creating instances of Properties
- Since:
- 0.3
- Version:
- 2.2.1
- Author:
- Michael Grove
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionbuild()Return the created Properties instancestatic PropertiesBuildercreate()Create a new PropertiesBuilderstatic Propertiesstatic PropertiesBuilderCreate a new PropertiesBuilderstatic PropertiesBuildercreate(Properties theProps) Create a new PropertiesBuilderGet the specified property from this builder.static PropertiespropertiesFromFile(Path theSource) static PropertiespropertiesFromString(String theContents) The inverse ofpropertiesToString(Properties).static StringpropertiesToString(Properties properties) static StringpropertiesToString(Properties properties, boolean includeTimestamp) Remove the specified propertySet the specified property key-value pairtoString()withPrefix(String thePrefix)
-
Method Details
-
create
Create a new PropertiesBuilder- Returns:
- a new builder
-
create
Create a new PropertiesBuilder- Parameters:
theProps- create a new builder starting from the provided set of properties. A copy of these properties are made, the original remains unaltered by the builder.- Returns:
- a new builder
-
create
Create a new PropertiesBuilder- Parameters:
theSource- create a new builder starting from the provided properties file.- Returns:
- a new builder
-
create
-
get
Get the specified property from this builder.- Parameters:
theKey- the key- Returns:
- the value or null if not set
-
set
Set the specified property key-value pair- Parameters:
theKey- the keytheValue- the value- Returns:
- this builder
-
remove
Remove the specified property- Parameters:
theKey- the key- Returns:
- this builder
-
setTrue
-
setFalse
-
withPrefix
-
toString
-
build
Return the created Properties instance- Returns:
- the properties
-
propertiesToString
-
propertiesToString
-
propertiesFromString
The inverse ofpropertiesToString(Properties).Reads with a
Reader, to match the onepropertiesToStringwrites with. Encoding the string as UTF-8 and handing it toProperties.load(java.io.InputStream), which decodes ISO-8859-1, mangled every character outside of ASCII, so a data source option carrying the contents of a file came back garbled everywhere it was read. Deterministically: the node the data source was added on holds the options the client sent and never reads them back, so it alone had the content intact, and only until it restarted.Values are still trimmed,
EnhancedPropertiesbeing what they are read into, and equally trimmed on their way in, so what a round trip returns is what the writer holds. -
propertiesFromFile
-