Class PropertyNode

  • All Implemented Interfaces:
    HasChildren

    public final class PropertyNode
    extends Object
    implements HasChildren
    An object that allows type-safe retrieval of property values and navigation to child properties.
    • Constructor Detail

    • Method Detail

      • child

        public PropertyNode child​(String reference)
        Navigates to the given child node.
        Specified by:
        child in interface HasChildren
        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

        public Value<String> stringValue()
        Gets the property value as a string.
        Returns:
        the string
      • booleanValue

        public Value<Boolean> booleanValue()
        Parses the property value as a boolean.
        Returns:
        the boolean
      • intValue

        public Value<Integer> intValue()
        Parses the property value as an integer.
        Returns:
        the integer
      • longValue

        public Value<Long> longValue()
        Parses the property value as a long.
        Returns:
        the long
      • bigDecimalValue

        public Value<BigDecimal> bigDecimalValue()
        Parses the property value as a big decimal.
        Returns:
        the big decimal
      • pathValue

        public Value<Path> pathValue()
        Interprets the property value as an absolute path.
        Returns:
        the absolute path
      • pathValue

        public Value<Path> pathValue​(Path basePath)
        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

        public Value<URL> urlValue()
        Parses the property value as an absolute URL.
        Returns:
        the URL
      • urlValue

        public Value<URL> urlValue​(URL context)
        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

        public Value<UrlRef> urlRefValue()
        Parses the property value as a UrlRef.
        Returns:
        the UrlRef
      • unixTimestampValue

        public Value<Instant> unixTimestampValue()
        Parses a string containing the number of seconds from the epoch of 1970-01-01T00:00:00Z.
        Returns:
        the instant
      • readableDuration

        public Value<Duration> readableDuration()
        Parses a string such as 30 seconds.
        Returns:
        the duration
      • stringsValue

        public Value<Stream<String>> 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

        public Value<Stream<PropertyNode>> 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 as stringsValue().
        Returns:
        the property nodes
      • convertedValue

        public <T> Value<T> convertedValue​(Function<String,​T> valueConversionFunction)
        Parses the property value using the given function.
        Returns:
        the converted value