Package com.complexible.common.base
Class PropertiesBuilder
- java.lang.Object
-
- com.complexible.common.base.PropertiesBuilder
-
public final class PropertiesBuilder extends java.lang.Object
Simple 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 class
PropertiesBuilder.PrefixedPropertiesBuilder
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Properties
build()
Return the created Properties instancestatic PropertiesBuilder
create()
Create a new PropertiesBuilderstatic java.util.Properties
create(java.lang.String... optionPairs)
static PropertiesBuilder
create(java.nio.file.Path theSource)
Create a new PropertiesBuilderstatic PropertiesBuilder
create(java.util.Properties theProps)
Create a new PropertiesBuilderjava.lang.String
get(java.lang.String theKey)
Get the specified property from this builder.static java.util.Properties
propertiesFromFile(java.nio.file.Path theSource)
static java.util.Properties
propertiesFromString(java.lang.String theContents)
static java.lang.String
propertiesToString(java.util.Properties properties)
PropertiesBuilder
remove(java.lang.String theKey)
Remove the specified propertyPropertiesBuilder
set(java.lang.String theKey, java.lang.String theValue)
Set the specified property key-value pairPropertiesBuilder
setFalse(java.lang.String theKey)
PropertiesBuilder
setTrue(java.lang.String theKey)
java.lang.String
toString()
PropertiesBuilder.PrefixedPropertiesBuilder
withPrefix(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:
toString
in 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)
-
-