Package com.backpackcloud.zipper
Interface Configuration
-
- All Known Implementing Classes:
ConfigurationChain,EnvironmentVariableConfiguration,FileConfiguration,NotSuppliedConfiguration,RawValueConfiguration,ResourceConfiguration,SystemPropertyConfiguration,UrlConfiguration
public interface Configuration extends Supplier<String>
Interface that defines a configuration that can be supplied via different sources.- Author:
- Marcelo GuimarĂ£es
-
-
Field Summary
Fields Modifier and Type Field Description static ConfigurationNOT_SUPPLIEDRepresents a not supplied configuration.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanasBoolean()Gets the value of this configuration as anboolean.default intasInt()Gets the value of this configuration as anint.default longasLong()Gets the value of this configuration as anlong.static ConfigurationChainconfiguration()Stringget()Gets the value of this configuration.booleanisSet()Checks if this source has some configuration set.default Configurationor(Configuration defaultConfiguration)Returns this configuration if it's set or the given default configuration otherwise.default Stringor(Supplier<String> supplier)default booleanorElse(boolean defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.default intorElse(int defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.default longorElse(long defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.default StringorElse(String defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.default Stringread()Assumes this configuration value is pointing to an external location and reads the value at that location.default List<String>readLines()Assumes this configuration value is pointing to an external location and reads the lines at that location.
-
-
-
Field Detail
-
NOT_SUPPLIED
static final Configuration NOT_SUPPLIED
Represents a not supplied configuration.
-
-
Method Detail
-
isSet
boolean isSet()
Checks if this source has some configuration set.- Returns:
trueif this source holds any configuration value.
-
get
String get()
Gets the value of this configuration.
-
asInt
default int asInt()
Gets the value of this configuration as anint.- Returns:
- an
intvalue defined by this configuration.
-
asLong
default long asLong()
Gets the value of this configuration as anlong.- Returns:
- a
longvalue defined by this configuration.
-
asBoolean
default boolean asBoolean()
Gets the value of this configuration as anboolean.- Returns:
- a
booleanvalue defined by this configuration.
-
read
default String read()
Assumes this configuration value is pointing to an external location and reads the value at that location.- Returns:
- the value stored in the location defined by this configuration.
-
readLines
default List<String> readLines()
Assumes this configuration value is pointing to an external location and reads the lines at that location.- Returns:
- the lines stored in the location defined by this configuration.
-
or
default Configuration or(Configuration defaultConfiguration)
Returns this configuration if it's set or the given default configuration otherwise.- Parameters:
defaultConfiguration- the default configuration to return- Returns:
- this configuration or the default one
-
orElse
default String orElse(String defaultValue)
Returns this configuration value if it'sset, otherwise returns the givendefaultValue.- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
default int orElse(int defaultValue)
Returns this configuration value if it'sset, otherwise returns the givendefaultValue.- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
default long orElse(long defaultValue)
Returns this configuration value if it'sset, otherwise returns the givendefaultValue.- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
default boolean orElse(boolean defaultValue)
Returns this configuration value if it'sset, otherwise returns the givendefaultValue.- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
configuration
static ConfigurationChain configuration()
-
-