public final class PropertiesSugar extends Object
Properties
precedences using ProfilePropertiesDecorator
,
ProfilePropertiesProjection
, ResourceProperties
or
PropertiesPrecedenceComposite
(and the like).Constructor and Description |
---|
PropertiesSugar() |
Modifier and Type | Method and Description |
---|---|
static Properties |
from(org.refcodes.structure.Property... aProperties)
Deprecated.
Implemented to see how it feels like using it in my sources
|
static org.refcodes.structure.Property |
from(String aKey,
String aValue)
Deprecated.
Implemented to see how it feels like using it in my sources
|
static Properties |
fromEnvironmentVariables()
Returns
Properties representing the operating system's
environment variables as of env on Linux or Unix shells or
set on Windows machines. |
static Properties |
fromProfile(Properties aProperties)
Wraps the
Properties with a profile projection. |
static Properties |
fromProfile(Properties aProperties,
String... aProfiles)
Wraps the
Properties with a profile projection. |
static Properties |
fromProperties(org.refcodes.structure.Property... aProperties)
Creates a
Properties instance from the provided Property
instances. |
static Properties |
fromSystemProperties()
Returns
Properties representing the system properties as passed
via the "-Dkey=value" when launching the JVM (e.g.java
-Dconsole.width=220). |
static Properties |
loadFromJavaProperties(File aFile)
Loads the Java properties from the given
File . |
static Properties |
loadFromJavaProperties(InputStream aInputStream)
Reads the properties from the given
InputStream . |
static Properties |
loadFromJavaProperties(String aFilePath)
Loads the Java properties from the given file's path.
|
static Properties |
loadFromJavaProperties(URL aUrl)
Loads the Java properties from the given
URL . |
static Properties |
loadFromJsonProperties(File aFile)
Loads the JSON properties from the given
File . |
static Properties |
loadFromJsonProperties(InputStream aInputStream)
Reads the properties from the given
InputStream . |
static Properties |
loadFromJsonProperties(String aFilePath)
Loads the JSON properties from the given file's path.
|
static Properties |
loadFromJsonProperties(URL aUrl)
Loads the JSON properties from the given
URL . |
static Properties |
loadFromTomlProperties(File aFile)
Loads the TOML properties from the given
File . |
static Properties |
loadFromTomlProperties(InputStream aInputStream)
Reads the properties from the given
InputStream . |
static Properties |
loadFromTomlProperties(String aFilePath)
Loads the TOML properties from the given file's path.
|
static Properties |
loadFromTomlProperties(URL aUrl)
Loads the TOML properties from the given
URL . |
static Properties |
loadFromYamlProperties(File aFile)
Loads the YAML properties from the given
File . |
static Properties |
loadFromYamlProperties(InputStream aInputStream)
Reads the properties from the given
InputStream . |
static Properties |
loadFromYamlProperties(String aFilePath)
Loads the YAML properties from the given file's path.
|
static Properties |
loadFromYamlProperties(URL aUrl)
Loads the YAML properties from the given
URL . |
static Properties |
seekFromJavaProperties(File aFile)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromJavaProperties(String aFilePath)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromJsonProperties(File aFile)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromJsonProperties(String aFilePath)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromTomlProperties(File aFile)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromTomlProperties(String aFilePath)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromYamlProperties(File aFile)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
seekFromYamlProperties(String aFilePath)
Loads a properties file from the file directly or (if not found) from
first folder containing such a file as of the specification for the
method
RuntimeUtility.toConfigDirs() . |
static Properties |
toNormalized(Properties aProperties)
Decorates the provided
Properties with additional behavior by
normalizing the key representing the path pointing to the according
value. |
static Properties |
toNormalized(Properties aProperties,
char[] aDelimiters)
Decorates the provided
Properties with additional behavior by
normalizing the key representing the path pointing to the according
value. |
static Properties |
toPrecedence(Properties... aProperties)
Creates a
Properties composite querying the provided
Properties in the given order. |
static org.refcodes.structure.Property |
toProperty(String aKey,
String aValue)
Creates a
Property from the provided key and the provided value. |
public static Properties loadFromJavaProperties(File aFile) throws IOException, ParseException
File
.
For Java properties, see "https://en.wikipedia.org/wiki/.properties".aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJavaProperties(String aFilePath) throws IOException, ParseException
aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJavaProperties(InputStream aInputStream) throws IOException, ParseException
InputStream
.
For Java properties, see "https://en.wikipedia.org/wiki/.properties".aInputStream
- The InputStream
from which to read the
properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJavaProperties(URL aUrl) throws IOException, ParseException
URL
.
For Java properties, see "https://en.wikipedia.org/wiki/.properties".aUrl
- The URL
from which to read the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromJavaProperties(File aFile) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For Java properties, see "https://en.wikipedia.org/wiki/.properties".aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromJavaProperties(String aFilePath) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For Java properties, see "https://en.wikipedia.org/wiki/.properties".aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromTomlProperties(File aFile) throws IOException, ParseException
File
.
For TOML properties, see "https://en.wikipedia.org/wiki/TOML"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromTomlProperties(String aFilePath) throws IOException, ParseException
aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromTomlProperties(InputStream aInputStream) throws IOException, ParseException
InputStream
.
For TOML properties, see "https://en.wikipedia.org/wiki/TOML"aInputStream
- The InputStream
from which to read the
properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromTomlProperties(URL aUrl) throws IOException, ParseException
URL
.
For TOML properties, see "https://en.wikipedia.org/wiki/TOML"aUrl
- The URL
from which to read the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromTomlProperties(File aFile) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For TOML properties, see "https://en.wikipedia.org/wiki/TOML"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromTomlProperties(String aFilePath) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For TOML properties, see "https://en.wikipedia.org/wiki/TOML"aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJsonProperties(File aFile) throws IOException, ParseException
File
.
For JSON properties, see "https://en.wikipedia.org/wiki/JSON"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJsonProperties(String aFilePath) throws IOException, ParseException
aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJsonProperties(InputStream aInputStream) throws IOException, ParseException
InputStream
.
For JSON properties, see "https://en.wikipedia.org/wiki/JSON"aInputStream
- The InputStream
from which to read the
properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromJsonProperties(URL aUrl) throws IOException, ParseException
URL
.
For JSON properties, see "https://en.wikipedia.org/wiki/JSON"aUrl
- The URL
from which to read the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromJsonProperties(File aFile) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For JSON properties, see "https://en.wikipedia.org/wiki/JSON"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromJsonProperties(String aFilePath) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For JSON properties, see "https://en.wikipedia.org/wiki/JSON"aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromYamlProperties(File aFile) throws IOException, ParseException
File
.
For YAML properties, see "https://en.wikipedia.org/wiki/YAML"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromYamlProperties(String aFilePath) throws IOException, ParseException
aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromYamlProperties(InputStream aInputStream) throws IOException, ParseException
InputStream
.
For YAML properties, see "https://en.wikipedia.org/wiki/YAML"aInputStream
- The InputStream
from which to read the
properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties loadFromYamlProperties(URL aUrl) throws IOException, ParseException
URL
.
For YAML properties, see "https://en.wikipedia.org/wiki/YAML"aUrl
- The URL
from which to read the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromYamlProperties(File aFile) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For YAML properties, see "https://en.wikipedia.org/wiki/YAML"aFile
- The File
from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties seekFromYamlProperties(String aFilePath) throws IOException, ParseException
RuntimeUtility.toConfigDirs()
.
For YAML properties, see "https://en.wikipedia.org/wiki/YAML"aFilePath
- The path to the file from which to load the properties.Properties
instance.IOException
- thrown in case accessing or processing the properties
file failed.ParseException
- Signals that an error has been reached
unexpectedly while parsing the data to be loaded.public static Properties toPrecedence(Properties... aProperties)
Properties
composite querying the provided
Properties
in the given order. Queried properties of the first
Properties
instance containing them are returned.
Properties
before have a higher precedence over
Properties
provided next.aProperties
- The Properties
to be queried in the provided
order.Properties
composite querying the provided properties
in the given order.public static Properties toNormalized(Properties aProperties)
Properties
with additional behavior by
normalizing the key representing the path pointing to the according
value.
You provide Properties
with a path delimiter different from the
default delimiter and you get Properties
which act as if the
delimiter was the default delimiter:
Paths containing the namespace delimiter "." (as of
Delimiter.NAMESPACE
are converted to paths' with delimiter "/"
(as of Delimiter.PATH
.
Changes applied to the provided Properties
affect the decorator.aProperties
- The Properties
to be decorated.Properties
decorator normalizing the the provided
Properties
' paths.public static Properties toNormalized(Properties aProperties, char[] aDelimiters)
Properties
with additional behavior by
normalizing the key representing the path pointing to the according
value.
You provide Properties
with a path delimiter different from the
default delimiter and you get Properties
which act as if the
delimiter was the default delimiter:
Paths containing the provided delimiters are converted to the paths' with
delimiter "/" (as of Delimiter.PATH
.
Changes applied to the provided Properties
affect the decorator.aProperties
- The Properties
to be decorated.aDelimiters
- The delimiters to be converted forth and backProperties
decorator normalizing the the provided
Properties
' paths.public static org.refcodes.structure.Property toProperty(String aKey, String aValue)
Property
from the provided key and the provided value.aKey
- The name of the property.aValue
- The value of the property.Property
representing the key/value-pair.public static org.refcodes.structure.Property from(String aKey, String aValue)
Property
from the provided key and the provided value.aKey
- The name of the property.aValue
- The value of the property.Property
representing the key/value-pair.public static Properties fromProperties(org.refcodes.structure.Property... aProperties)
Properties
instance from the provided Property
instances. Use toProperty(String, String)
to compose your
properties to be added.aProperties
- The Property
instances' key/value-pairs to be
added.Properties
containing the provided
Property
instances.public static Properties from(org.refcodes.structure.Property... aProperties)
Properties
instance from the provided Property
instances. Use toProperty(String, String)
to compose your
properties to be added.aProperties
- The Property
instances' key/value-pairs to be
added.Properties
containing the provided
Property
instances.public static Properties fromSystemProperties()
Properties
representing the system properties as passed
via the "-Dkey=value" when launching the JVM (e.g.java
-Dconsole.width=220).public static Properties fromEnvironmentVariables()
Properties
representing the operating system's
environment variables as of env
on Linux or Unix shells or
set
on Windows machines.public static Properties fromProfile(Properties aProperties, String... aProfiles)
Properties
with a profile projection. The
Properties
are decorated with a
ProfilePropertiesProjection
which represents the wrapped
Properties
with the given profiles applied. See also
ProfileProperties.toRuntimeProfile(String...)
.aProperties
- The properties which are to be projected according to
the provided profiles. The evaluation is done as of
ProfileProperties.toRuntimeProfile(String...)
.aProfiles
- The profiles to be used when constructing the
projection.Properties
projection as of the provided profiles.public static Properties fromProfile(Properties aProperties)
Properties
with a profile projection. The
Properties
are decorated with a
ProfilePropertiesProjection
which represents the wrapped
Properties
with the given profiles applied. See also
ProfileProperties.toRuntimeProfile(String...)
.
The profiles being used are found at the given Properties
"runtime/profiles" path as defined by
PropertiesPath.RUNTIME_PROFILES_PATH
. This path points to an
array with the Runtime-Profiles denoted as follows, pointing to your
active Runtime-Profiles:
runtime/profiles=local,oauth,development
This array beats the above kind of declaration so that the active
Runtime-Profiles can easily be overwritten by ProfileProperties
supporting Java System-Properties (passed to the JVM via "-Dx=y") e.g.
the RuntimePropertiesComposite
found in the
refcodes-runtime
artifact.aProperties
- The properties which are to be projected according to
the profiles provided by the given Properties
. The
evaluation is done as of
ProfileProperties.toRuntimeProfile()
.Properties
projection as of the profiles provided by
the given Properties
.Copyright © 2017. All rights reserved.