-
- All Known Implementing Classes:
PropertiesUtil
public interface PropertyEnvironment
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
addPropertySource(PropertySource propertySource)
Allows a PropertySource to be added after PropertiesUtil has been created.default boolean
getBooleanProperty(String name)
Gets the named property as a boolean value.default Boolean
getBooleanProperty(String[] prefixes, String key, Supplier<Boolean> supplier)
Retrieves a property that may be prefixed by more than one string.default boolean
getBooleanProperty(String name, boolean defaultValue)
Gets the named property as a boolean value.default boolean
getBooleanProperty(String name, boolean defaultValueIfAbsent, boolean defaultValueIfPresent)
Gets the named property as a boolean value.default boolean
getBooleanProperty(PropertyKey key)
Gets the named property as a boolean value.default boolean
getBooleanProperty(PropertyKey key, boolean defaultValue)
Gets the named property as a boolean value.default boolean
getBooleanProperty(PropertyKey key, boolean defaultValueIfAbsent, boolean defaultValueIfPresent)
Gets the named property as a boolean value.default Charset
getCharsetProperty(String name)
Gets the named property as a Charset value.default Charset
getCharsetProperty(String name, Charset defaultValue)
Gets the named property as a Charset value.default Charset
getCharsetProperty(PropertyKey key)
Gets the named property as a Charset value.default Charset
getCharsetProperty(PropertyKey key, Charset defaultValue)
Gets the named property as a Charset value.default Duration
getDurationProperty(String[] prefixes, String key, Supplier<Duration> supplier)
Retrieves a property that may be prefixed by more than one string.default Duration
getDurationProperty(String name, Duration defaultValue)
Retrieves a Duration where the String is of the format nnn[unit] where nnn represents an integer value and unit represents a time unit.default Duration
getDurationProperty(PropertyKey key, Duration defaultValue)
Retrieves a Duration where the String is of the format nnn[unit] where nnn represents an integer value and unit represents a time unit.default Integer
getIntegerProperty(String[] prefixes, String key, Supplier<Integer> supplier)
Retrieves a property that may be prefixed by more than one string.default int
getIntegerProperty(String name, int defaultValue)
Gets the named property as an integer.default int
getIntegerProperty(PropertyKey key, int defaultValue)
Gets the named property as an integer.default Long
getLongProperty(String[] prefixes, String key, Supplier<Long> supplier)
Retrieves a property that may be prefixed by more than one string.default long
getLongProperty(String name, long defaultValue)
Gets the named property as a long.default long
getLongProperty(PropertyKey key, long defaultValue)
Gets the named property as a long.String
getStringProperty(String name)
Gets the named property as a String.default String
getStringProperty(String[] prefixes, String key, Supplier<String> supplier)
Retrieves a property that may be prefixed by more than one string.default String
getStringProperty(String name, String defaultValue)
Gets the named property as a String.default String
getStringProperty(PropertyKey key)
Gets the named property as a String.default String
getStringProperty(PropertyKey key, String defaultValue)
Gets the named property as a String.boolean
hasProperty(String name)
Returnstrue
if the specified property is defined, regardless of its value (it may not have a value).default boolean
hasProperty(PropertyKey key)
Returnstrue
if the specified property is defined, regardless of its value (it may not have a value).default boolean
isOsWindows()
Returns true if system properties tell us we are running on Windows.
-
-
-
Method Detail
-
addPropertySource
void addPropertySource(PropertySource propertySource)
Allows a PropertySource to be added after PropertiesUtil has been created.- Parameters:
propertySource
- the PropertySource to add.
-
hasProperty
boolean hasProperty(String name)
Returnstrue
if the specified property is defined, regardless of its value (it may not have a value).- Parameters:
name
- the name of the property to verify- Returns:
true
if the specified property is defined, regardless of its value
-
hasProperty
default boolean hasProperty(PropertyKey key)
Returnstrue
if the specified property is defined, regardless of its value (it may not have a value).- Parameters:
nkey
- the key of the property to verify- Returns:
true
if the specified property is defined, regardless of its value
-
getBooleanProperty
default boolean getBooleanProperty(String name)
Gets the named property as a boolean value. If the property matches the string"true"
(case-insensitive), then it is returned as the boolean valuetrue
. Any other non-null
text in the property is consideredfalse
.- Parameters:
name
- the name of the property to look up- Returns:
- the boolean value of the property or
false
if undefined.
-
getBooleanProperty
default boolean getBooleanProperty(String name, boolean defaultValue)
Gets the named property as a boolean value.- Parameters:
name
- the name of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the boolean value of the property or
defaultValue
if undefined.
-
getBooleanProperty
default boolean getBooleanProperty(PropertyKey key)
Gets the named property as a boolean value.- Parameters:
key
- the key of the property to look up- Returns:
- the boolean value of the property or
defaultValue
if undefined.
-
getBooleanProperty
default boolean getBooleanProperty(PropertyKey key, boolean defaultValue)
Gets the named property as a boolean value.- Parameters:
key
- the key of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the boolean value of the property or
defaultValue
if undefined.
-
getBooleanProperty
default boolean getBooleanProperty(String name, boolean defaultValueIfAbsent, boolean defaultValueIfPresent)
Gets the named property as a boolean value.- Parameters:
name
- the name of the property to look updefaultValueIfAbsent
- the default value to use if the property is undefineddefaultValueIfPresent
- the default value to use if the property is defined but not assigned- Returns:
- the boolean value of the property or
defaultValue
if undefined.
-
getBooleanProperty
default boolean getBooleanProperty(PropertyKey key, boolean defaultValueIfAbsent, boolean defaultValueIfPresent)
Gets the named property as a boolean value.- Parameters:
key
- the key of the property to look updefaultValueIfAbsent
- the default value to use if the property is undefineddefaultValueIfPresent
- the default value to use if the property is defined but not assigned- Returns:
- the boolean value of the property or
defaultValue
if undefined.
-
getBooleanProperty
default Boolean getBooleanProperty(String[] prefixes, String key, Supplier<Boolean> supplier)
Retrieves a property that may be prefixed by more than one string.- Parameters:
prefixes
- The array of prefixes.key
- The key to locate.supplier
- The method to call to derive the default value. If the value is null, null will be returned if no property is found.- Returns:
- The value or null if it is not found.
- Since:
- 2.13.0
-
getCharsetProperty
default Charset getCharsetProperty(String name)
Gets the named property as a Charset value.- Parameters:
name
- the name of the property to look up- Returns:
- the Charset value of the property or
Charset.defaultCharset()
if undefined.
-
getCharsetProperty
default Charset getCharsetProperty(PropertyKey key)
Gets the named property as a Charset value.- Parameters:
key
- the key of the property to look up- Returns:
- the Charset value of the property or
Charset.defaultCharset()
if undefined.
-
getCharsetProperty
default Charset getCharsetProperty(PropertyKey key, Charset defaultValue)
Gets the named property as a Charset value.- Parameters:
key
- the key of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the Charset value of the property or
Charset.defaultCharset()
if undefined.
-
getCharsetProperty
default Charset getCharsetProperty(String name, Charset defaultValue)
Gets the named property as a Charset value. If we cannot find the named Charset, see if it is mapped in fileLog4j-charsets.properties
on the class path.- Parameters:
name
- the name of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the Charset value of the property or
defaultValue
if undefined.
-
getIntegerProperty
default int getIntegerProperty(String name, int defaultValue)
Gets the named property as an integer.- Parameters:
name
- the name of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the parsed integer value of the property or
defaultValue
if it was undefined or could not be parsed.
-
getIntegerProperty
default int getIntegerProperty(PropertyKey key, int defaultValue)
Gets the named property as an integer.- Parameters:
key
- the key of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the parsed integer value of the property or
defaultValue
if it was undefined or could not be parsed.
-
getIntegerProperty
default Integer getIntegerProperty(String[] prefixes, String key, Supplier<Integer> supplier)
Retrieves a property that may be prefixed by more than one string.- Parameters:
prefixes
- The array of prefixes.key
- The key to locate.supplier
- The method to call to derive the default value. If the value is null, null will be returned if no property is found.- Returns:
- The value or null if it is not found.
- Since:
- 2.13.0
-
getLongProperty
default long getLongProperty(PropertyKey key, long defaultValue)
Gets the named property as a long.- Parameters:
key
- the key of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the parsed long value of the property or
defaultValue
if it was undefined or could not be parsed.
-
getLongProperty
default long getLongProperty(String name, long defaultValue)
Gets the named property as a long.- Parameters:
component
- the owning component of the propertyname
- the name of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the parsed long value of the property or
defaultValue
if it was undefined or could not be parsed.
-
getLongProperty
default Long getLongProperty(String[] prefixes, String key, Supplier<Long> supplier)
Retrieves a property that may be prefixed by more than one string.- Parameters:
prefixes
- The array of prefixes.key
- The key to locate.supplier
- The method to call to derive the default value. If the value is null, null will be returned if no property is found.- Returns:
- The value or null if it is not found.
- Since:
- 2.13.0
-
getDurationProperty
default Duration getDurationProperty(PropertyKey key, Duration defaultValue)
Retrieves a Duration where the String is of the format nnn[unit] where nnn represents an integer value and unit represents a time unit.- Parameters:
key
- The key for the property.defaultValue
- The default value.- Returns:
- The value of the String as a Duration or the default value, which may be null.
- Since:
- 2.13.0
-
getDurationProperty
default Duration getDurationProperty(String name, Duration defaultValue)
Retrieves a Duration where the String is of the format nnn[unit] where nnn represents an integer value and unit represents a time unit.- Parameters:
name
- The property name.defaultValue
- The default value.- Returns:
- The value of the String as a Duration or the default value, which may be null.
- Since:
- 2.13.0
-
getDurationProperty
default Duration getDurationProperty(String[] prefixes, String key, Supplier<Duration> supplier)
Retrieves a property that may be prefixed by more than one string.- Parameters:
prefixes
- The array of prefixes.key
- The key to locate.supplier
- The method to call to derive the default value. If the value is null, null will be returned if no property is found.- Returns:
- The value or null if it is not found.
- Since:
- 2.13.0
-
getStringProperty
default String getStringProperty(String[] prefixes, String key, Supplier<String> supplier)
Retrieves a property that may be prefixed by more than one string.- Parameters:
prefixes
- The array of prefixes.key
- The key to locate.supplier
- The method to call to derive the default value. If the value is null, null will be returned if no property is found.- Returns:
- The value or null if it is not found.
- Since:
- 2.13.0
-
getStringProperty
default String getStringProperty(PropertyKey key)
Gets the named property as a String.- Parameters:
key
- the key of the property to look up- Returns:
- the String value of the property or
null
if undefined.
-
getStringProperty
String getStringProperty(String name)
Gets the named property as a String.- Parameters:
name
- the name of the property to look up- Returns:
- the String value of the property or
null
if undefined.
-
getStringProperty
default String getStringProperty(PropertyKey key, String defaultValue)
Gets the named property as a String.- Parameters:
key
- the key of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the String value of the property or
defaultValue
if undefined.
-
getStringProperty
default String getStringProperty(String name, String defaultValue)
Gets the named property as a String.- Parameters:
name
- the name of the property to look updefaultValue
- the default value to use if the property is undefined- Returns:
- the String value of the property or
defaultValue
if undefined.
-
isOsWindows
default boolean isOsWindows()
Returns true if system properties tell us we are running on Windows.- Returns:
- true if system properties tell us we are running on Windows.
-
-