java.lang.Object
is.codion.common.Configuration
A utility class for central configuration values.
Parses a property file on class load, specified by the
Note that if
is not found a
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Indicates that a required configuration file was not found. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Specifies the main configuration file.
Prefix with 'classpath:' to indicate that the configuration file is on the classpath.static final String
Specifies whether the application requires a configuration file to run.
If this is set to true and the file referenced byCONFIGURATION_FILE
is not found aConfiguration.ConfigurationFileNotFoundException
is thrown when this class is loaded.
Value type: Boolean
Default value: false -
Method Summary
Modifier and TypeMethodDescriptionstatic PropertyValue<Boolean>
booleanValue
(String key) Creates a boolean configuration valuestatic PropertyValue<Boolean>
booleanValue
(String key, boolean defaultValue) Creates a boolean configuration valuestatic PropertyValue<Character>
characterValue
(String key) Creates a character configuration valuestatic PropertyValue<Character>
characterValue
(String key, char defaultValue) Creates a character configuration valuestatic PropertyValue<Double>
doubleValue
(String key) Creates a double configuration valuestatic PropertyValue<Double>
doubleValue
(String key, double defaultValue) Creates a double configuration valuestatic <T extends Enum<T>>
PropertyValue<T>Creates an enum configuration valuestatic <T extends Enum<T>>
PropertyValue<T>Creates an enum configuration valuestatic PropertyValue<Integer>
integerValue
(String key) Creates an integer configuration valuestatic PropertyValue<Integer>
integerValue
(String key, int defaultValue) Creates an integer configuration valuestatic <T> PropertyValue<List<T>>
Creates a list configuration valuestatic <T> PropertyValue<List<T>>
Creates a list configuration valuestatic PropertyValue<Long>
Creates a long configuration valuestatic PropertyValue<Long>
Creates a long configuration valuestatic PropertyValue<String>
stringValue
(String key) Creates a string configuration valuestatic PropertyValue<String>
stringValue
(String key, String defaultValue) Creates a string configuration valuestatic <T> PropertyValue<T>
Creates a configuration valuestatic <T> PropertyValue<T>
Creates a configuration value
-
Field Details
-
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
Specifies whether the application requires a configuration file to run.
If this is set to true and the file referenced byCONFIGURATION_FILE
is not found aConfiguration.ConfigurationFileNotFoundException
is thrown when this class is loaded.
Value type: Boolean
Default value: false- See Also:
-
-
Method Details
-
booleanValue
Creates a boolean configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
booleanValue
Creates a boolean configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
integerValue
Creates an integer configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
integerValue
Creates an integer configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
longValue
Creates a long configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
longValue
Creates a long configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
doubleValue
Creates a double configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
doubleValue
Creates a double configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
characterValue
Creates a character configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
characterValue
Creates a character configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
stringValue
Creates a string configuration value- Parameters:
key
- the configuration value key- Returns:
- a configuration value builder
-
stringValue
Creates a string configuration value- Parameters:
key
- the configuration value keydefaultValue
- the default value- Returns:
- a configuration value builder
-
enumValue
Creates an enum configuration value- Type Parameters:
T
- the enum type- Parameters:
key
- the configuration value keyenumClass
- 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 keyenumClass
- the enum classdefaultValue
- the default value- Returns:
- a configuration value builder
-
listValue
Creates a list configuration value- Type Parameters:
T
- the value type- Parameters:
key
- the configuration value keyparser
- 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 keyparser
- the parser used to parse a string representation of the valuedefaultValue
- the default value- Returns:
- a configuration value builder
-
value
Creates a configuration value- Type Parameters:
T
- the value type- Parameters:
key
- the configuration value keyparser
- the parser used to parse a string representation of the value- Returns:
- a configuration value builder
-
value
Creates a configuration value- Type Parameters:
T
- the value type- Parameters:
key
- the configuration value keyparser
- the parser used to parse a string representation of the valuedefaultValue
- the default value- Returns:
- a configuration value builder
-