Class 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
    • 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 key
        theValue - the value
        Returns:
        this builder
      • remove

        public PropertiesBuilder remove​(java.lang.String theKey)
        Remove the specified property
        Parameters:
        theKey - the key
        Returns:
        this builder
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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)