Class PropertiesBuilder

java.lang.Object
com.complexible.common.base.PropertiesBuilder

public final class PropertiesBuilder extends Object

Simple builder class for creating instances of Properties

Since:
0.3
Version:
2.2.1
Author:
Michael Grove
  • Method Details

    • create

      public static PropertiesBuilder create()
      Create a new PropertiesBuilder
      Returns:
      a new builder
    • create

      public static PropertiesBuilder create(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(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 Properties create(String... optionPairs)
    • get

      public String get(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(String theKey, String theValue)
      Set the specified property key-value pair
      Parameters:
      theKey - the key
      theValue - the value
      Returns:
      this builder
    • remove

      public PropertiesBuilder remove(String theKey)
      Remove the specified property
      Parameters:
      theKey - the key
      Returns:
      this builder
    • setTrue

      public PropertiesBuilder setTrue(String theKey)
    • setFalse

      public PropertiesBuilder setFalse(String theKey)
    • withPrefix

      public PropertiesBuilder.PrefixedPropertiesBuilder withPrefix(String thePrefix)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • build

      public Properties build()
      Return the created Properties instance
      Returns:
      the properties
    • propertiesToString

      public static String propertiesToString(Properties properties)
    • propertiesToString

      public static String propertiesToString(Properties properties, boolean includeTimestamp)
    • propertiesFromString

      public static Properties propertiesFromString(String theContents)
    • propertiesFromFile

      public static Properties propertiesFromFile(Path theSource)