Class Configuration

java.lang.Object
is.codion.common.Configuration

public final class Configuration extends Object
A utility class for central configuration values.

Parses a property file on class load, specified by the CONFIGURATION_FILE system property.

Note that if CONFIGURATION_FILE_REQUIRED is true and the file referenced by CONFIGURATION_FILE is not found a Configuration.ConfigurationFileNotFoundException is thrown when this class is loaded.

See Also:
  • Field Details

    • CONFIGURATION_FILE

      public static final String CONFIGURATION_FILE
      Specifies the main configuration file.
      Prefix with 'classpath:' to indicate that the configuration file is on the classpath.
      • Value type: String
      • Default value: null
      See Also:
    • CONFIGURATION_FILE_REQUIRED

      public static final String CONFIGURATION_FILE_REQUIRED
      Specifies whether the application requires a configuration file to run.
      If this is set to true and the file referenced by CONFIGURATION_FILE
      is not found a Configuration.ConfigurationFileNotFoundException is thrown when this class is loaded.
      • Value type: Boolean
      • Default value: false
      See Also:
  • Method Details

    • booleanValue

      public static PropertyValue<Boolean> booleanValue(String key)
      Creates a boolean configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • booleanValue

      public static PropertyValue<Boolean> booleanValue(String key, boolean defaultValue)
      Creates a boolean configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • integerValue

      public static PropertyValue<Integer> integerValue(String key)
      Creates an integer configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • integerValue

      public static PropertyValue<Integer> integerValue(String key, int defaultValue)
      Creates an integer configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • longValue

      public static PropertyValue<Long> longValue(String key)
      Creates a long configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • longValue

      public static PropertyValue<Long> longValue(String key, long defaultValue)
      Creates a long configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • doubleValue

      public static PropertyValue<Double> doubleValue(String key)
      Creates a double configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • doubleValue

      public static PropertyValue<Double> doubleValue(String key, double defaultValue)
      Creates a double configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • characterValue

      public static PropertyValue<Character> characterValue(String key)
      Creates a character configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • characterValue

      public static PropertyValue<Character> characterValue(String key, char defaultValue)
      Creates a character configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • stringValue

      public static PropertyValue<String> stringValue(String key)
      Creates a string configuration value
      Parameters:
      key - the configuration value key
      Returns:
      a configuration value builder
    • stringValue

      public static PropertyValue<String> stringValue(String key, String defaultValue)
      Creates a string configuration value
      Parameters:
      key - the configuration value key
      defaultValue - the default value
      Returns:
      a configuration value builder
    • enumValue

      public static <T extends Enum<T>> PropertyValue<T> enumValue(String key, Class<T> enumClass)
      Creates an enum configuration value
      Type Parameters:
      T - the enum type
      Parameters:
      key - the configuration value key
      enumClass - the enum class
      Returns:
      a configuration value builder
    • enumValue

      public static <T extends Enum<T>> PropertyValue<T> enumValue(String key, Class<T> enumClass, T defaultValue)
      Creates an enum configuration value
      Type Parameters:
      T - the enum type
      Parameters:
      key - the configuration value key
      enumClass - the enum class
      defaultValue - the default value
      Returns:
      a configuration value builder
    • listValue

      public static <T> PropertyValue<List<T>> listValue(String key, Function<String,T> parser)
      Creates a list configuration value
      Type Parameters:
      T - the value type
      Parameters:
      key - the configuration value key
      parser - the parser used to parse a string representation of the value
      Returns:
      a configuration value builder
    • listValue

      public static <T> PropertyValue<List<T>> listValue(String key, Function<String,T> parser, List<T> defaultValue)
      Creates a list configuration value
      Type Parameters:
      T - the value type
      Parameters:
      key - the configuration value key
      parser - the parser used to parse a string representation of the value
      defaultValue - the default value
      Returns:
      a configuration value builder
    • value

      public static <T> PropertyValue<T> value(String key, Function<String,T> parser)
      Creates a configuration value
      Type Parameters:
      T - the value type
      Parameters:
      key - the configuration value key
      parser - the parser used to parse a string representation of the value
      Returns:
      a configuration value builder
    • value

      public static <T> PropertyValue<T> value(String key, Function<String,T> parser, T defaultValue)
      Creates a configuration value
      Type Parameters:
      T - the value type
      Parameters:
      key - the configuration value key
      parser - the parser used to parse a string representation of the value
      defaultValue - the default value
      Returns:
      a configuration value builder