Package com.complexible.common.base
Class PropertiesBuilder
- java.lang.Object
-
- com.complexible.common.base.PropertiesBuilder
-
public final class PropertiesBuilder extends java.lang.ObjectSimple builder class for creating instances of
Properties- Since:
- 0.3
- Version:
- 2.2.1
- Author:
- Michael Grove
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classPropertiesBuilder.PrefixedPropertiesBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Propertiesbuild()Return the created Properties instancestatic PropertiesBuildercreate()Create a new PropertiesBuilderstatic java.util.Propertiescreate(java.lang.String... optionPairs)static PropertiesBuildercreate(java.nio.file.Path theSource)Create a new PropertiesBuilderstatic PropertiesBuildercreate(java.util.Properties theProps)Create a new PropertiesBuilderjava.lang.Stringget(java.lang.String theKey)Get the specified property from this builder.static java.util.PropertiespropertiesFromFile(java.nio.file.Path theSource)static java.util.PropertiespropertiesFromString(java.lang.String theContents)static java.lang.StringpropertiesToString(java.util.Properties properties)PropertiesBuilderremove(java.lang.String theKey)Remove the specified propertyPropertiesBuilderset(java.lang.String theKey, java.lang.String theValue)Set the specified property key-value pairPropertiesBuildersetFalse(java.lang.String theKey)PropertiesBuildersetTrue(java.lang.String theKey)java.lang.StringtoString()PropertiesBuilder.PrefixedPropertiesBuilderwithPrefix(java.lang.String thePrefix)
-
-
-
Method Detail
-
create
public static PropertiesBuilder create()
Create a new PropertiesBuilder- Returns:
- a new builder
-
create
public static PropertiesBuilder create(java.util.Properties theProps)
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
public static PropertiesBuilder create(java.nio.file.Path theSource)
Create a new PropertiesBuilder- Parameters:
theSource- create a new builder starting from the provided properties file.- Returns:
- a new builder
-
create
public static java.util.Properties create(java.lang.String... optionPairs)
-
get
public java.lang.String get(java.lang.String theKey)
Get the specified property from this builder.- Parameters:
theKey- the key- Returns:
- the value or null if not set
-
set
public PropertiesBuilder set(java.lang.String theKey, java.lang.String theValue)
Set the specified property key-value pair- Parameters:
theKey- the keytheValue- the value- Returns:
- this builder
-
remove
public PropertiesBuilder remove(java.lang.String theKey)
Remove the specified property- Parameters:
theKey- the key- Returns:
- this builder
-
setTrue
public PropertiesBuilder setTrue(java.lang.String theKey)
-
setFalse
public PropertiesBuilder setFalse(java.lang.String theKey)
-
withPrefix
public PropertiesBuilder.PrefixedPropertiesBuilder withPrefix(java.lang.String thePrefix)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
build
public java.util.Properties build()
Return the created Properties instance- Returns:
- the properties
-
propertiesToString
public static java.lang.String propertiesToString(java.util.Properties properties)
-
propertiesFromString
public static java.util.Properties propertiesFromString(java.lang.String theContents)
-
propertiesFromFile
public static java.util.Properties propertiesFromFile(java.nio.file.Path theSource)
-
-