Class PropertyNode
java.lang.Object
com.github.mizool.core.configuration.PropertyNode
- All Implemented Interfaces:
HasChildren
An object that allows type-safe retrieval of property values and navigation to child properties.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionParses the property value as a big decimal.Parses the property value as a boolean.Navigates to the given child node.<T> Value<T>
convertedValue
(Function<String, T> valueConversionFunction) Parses the property value using the given function.intValue()
Parses the property value as an integer.Parses a string such asPT7H
usingDuration.parse(CharSequence)
.Parses a string such asP5Y12M7D
usingPeriod.parse(CharSequence)
.Parses the property value as a long.Interprets the property value as an absolute path.Interprets the property value as a relative path for the given base path.Parses a string such as30 seconds
.Parses a comma-separated list of references and returns the respective property nodes.
Absolute and relative references
To increase readability of properties files, users can reference child nodes with a shortened syntax: if a reference starts with a '.
', it is resolved starting with the current node (relative reference).Parses a comma-separated list of values.Gets the property value as a string.toString()
Parses a string containing the number of seconds from the epoch of 1970-01-01T00:00:00Z.Parses the property value as aUrlRef
.urlValue()
Parses the property value as an absolute URL.Interprets the property value as a relative URL for the given context.Parses a string such as2020-08-14T12:04:22.00Z
usingDateTimeFormatter.ISO_INSTANT
.Parses a string such asEurope/Berlin
usingZoneId.of(String)
.
-
Constructor Details
-
PropertyNode
-
-
Method Details
-
child
Navigates to the given child node.- Specified by:
child
in interfaceHasChildren
- Parameters:
reference
- one or more segments of the key to append to the key of the current node- Returns:
- the child or descendant node, never
null
.
-
stringValue
Gets the property value as a string.- Returns:
- the string
-
booleanValue
Parses the property value as a boolean.- Returns:
- the boolean
-
intValue
Parses the property value as an integer.- Returns:
- the integer
-
longValue
Parses the property value as a long.- Returns:
- the long
-
bigDecimalValue
Parses the property value as a big decimal.- Returns:
- the big decimal
-
pathValue
Interprets the property value as an absolute path.- Returns:
- the absolute path
-
pathValue
Interprets the property value as a relative path for the given base path.- Parameters:
basePath
- the path the property value is relative to- Returns:
- the combined, absolute path
-
urlValue
Parses the property value as an absolute URL.- Returns:
- the URL
-
urlValue
Interprets the property value as a relative URL for the given context.- Parameters:
context
- the URL the property value is relative to- Returns:
- the combined, absolute URL
-
urlRefValue
Parses the property value as aUrlRef
.- Returns:
- the UrlRef
-
unixTimestampValue
Parses a string containing the number of seconds from the epoch of 1970-01-01T00:00:00Z.- Returns:
- the instant
-
utcInstantValue
Parses a string such as2020-08-14T12:04:22.00Z
usingDateTimeFormatter.ISO_INSTANT
.- Returns:
- the instant
-
readableDuration
Parses a string such as30 seconds
.- Returns:
- the duration
-
isoDurationValue
Parses a string such asPT7H
usingDuration.parse(CharSequence)
.- Returns:
- the duration
-
isoPeriodValue
Parses a string such asP5Y12M7D
usingPeriod.parse(CharSequence)
.- Returns:
- the period
-
zoneIdValue
Parses a string such asEurope/Berlin
usingZoneId.of(String)
.- Returns:
- the zone ID
-
stringsValue
Parses a comma-separated list of values. Empty and whitespace-only elements are skipped, and leading and trailing whitespace inside each value is removed.- Returns:
- the values
-
referencedNodes
Parses a comma-separated list of references and returns the respective property nodes.
Absolute and relative references
To increase readability of properties files, users can reference child nodes with a shortened syntax: if a reference starts with a '.
', it is resolved starting with the current node (relative reference). Other references are resolved starting with the root node (absolute reference).
Whitespace
Whitespace is handled the same way asstringsValue()
.- Returns:
- the property nodes
-
convertedValue
Parses the property value using the given function.- Returns:
- the converted value
-
toString
-