Class ConfigurationChain
- java.lang.Object
-
- com.backpackcloud.zipper.impl.configuration.ConfigurationChain
-
- All Implemented Interfaces:
Configuration,Supplier<String>
public class ConfigurationChain extends Object implements Configuration
-
-
Field Summary
-
Fields inherited from interface com.backpackcloud.zipper.Configuration
NOT_SUPPLIED
-
-
Constructor Summary
Constructors Constructor Description ConfigurationChain(Configuration configuration)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanasBoolean()Gets the value of this configuration as anboolean.intasInt()Gets the value of this configuration as anint.longasLong()Gets the value of this configuration as anlong.ConfigurationChainenv(String key)ConfigurationChainfile(String key)Stringget()Gets the value of this configuration.booleanisSet()Checks if this source has some configuration set.Configurationor(Configuration defaultConfiguration)Returns this configuration if it's set or the given default configuration otherwise.Stringor(Supplier<String> supplier)booleanorElse(boolean defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.intorElse(int defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.longorElse(long defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.StringorElse(String defaultValue)Returns this configuration value if it'sset, otherwise returns the givendefaultValue.ConfigurationChainproperty(String key)Stringread()Assumes this configuration value is pointing to an external location and reads the value at that location.List<String>readLines()Assumes this configuration value is pointing to an external location and reads the lines at that location.ConfigurationChainresource(String key)ConfigurationChainurl(String key)ConfigurationChainvalue(String key)
-
-
-
Constructor Detail
-
ConfigurationChain
public ConfigurationChain(Configuration configuration)
-
-
Method Detail
-
isSet
public boolean isSet()
Description copied from interface:ConfigurationChecks if this source has some configuration set.- Specified by:
isSetin interfaceConfiguration- Returns:
trueif this source holds any configuration value.
-
get
public String get()
Description copied from interface:ConfigurationGets the value of this configuration.- Specified by:
getin interfaceConfiguration- Specified by:
getin interfaceSupplier<String>- Returns:
- the configuration value.
-
asInt
public int asInt()
Description copied from interface:ConfigurationGets the value of this configuration as anint.- Specified by:
asIntin interfaceConfiguration- Returns:
- an
intvalue defined by this configuration.
-
asLong
public long asLong()
Description copied from interface:ConfigurationGets the value of this configuration as anlong.- Specified by:
asLongin interfaceConfiguration- Returns:
- a
longvalue defined by this configuration.
-
asBoolean
public boolean asBoolean()
Description copied from interface:ConfigurationGets the value of this configuration as anboolean.- Specified by:
asBooleanin interfaceConfiguration- Returns:
- a
booleanvalue defined by this configuration.
-
read
public String read()
Description copied from interface:ConfigurationAssumes this configuration value is pointing to an external location and reads the value at that location.- Specified by:
readin interfaceConfiguration- Returns:
- the value stored in the location defined by this configuration.
-
readLines
public List<String> readLines()
Description copied from interface:ConfigurationAssumes this configuration value is pointing to an external location and reads the lines at that location.- Specified by:
readLinesin interfaceConfiguration- Returns:
- the lines stored in the location defined by this configuration.
-
or
public Configuration or(Configuration defaultConfiguration)
Description copied from interface:ConfigurationReturns this configuration if it's set or the given default configuration otherwise.- Specified by:
orin interfaceConfiguration- Parameters:
defaultConfiguration- the default configuration to return- Returns:
- this configuration or the default one
-
or
public String or(Supplier<String> supplier)
- Specified by:
orin interfaceConfiguration
-
orElse
public String orElse(String defaultValue)
Description copied from interface:ConfigurationReturns this configuration value if it'sset, otherwise returns the givendefaultValue.- Specified by:
orElsein interfaceConfiguration- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
public int orElse(int defaultValue)
Description copied from interface:ConfigurationReturns this configuration value if it'sset, otherwise returns the givendefaultValue.- Specified by:
orElsein interfaceConfiguration- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
public long orElse(long defaultValue)
Description copied from interface:ConfigurationReturns this configuration value if it'sset, otherwise returns the givendefaultValue.- Specified by:
orElsein interfaceConfiguration- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
orElse
public boolean orElse(boolean defaultValue)
Description copied from interface:ConfigurationReturns this configuration value if it'sset, otherwise returns the givendefaultValue.- Specified by:
orElsein interfaceConfiguration- Parameters:
defaultValue- the default value to return- Returns:
- this configuration value or the default value in case this configuration is not set.
-
env
public ConfigurationChain env(String key)
-
file
public ConfigurationChain file(String key)
-
resource
public ConfigurationChain resource(String key)
-
property
public ConfigurationChain property(String key)
-
url
public ConfigurationChain url(String key)
-
value
public ConfigurationChain value(String key)
-
-