Interface Conf
-
- All Known Implementing Classes:
AbstractConf
,ArgsConf
,AzkarraConf
,DelegatingConf
,EmptyConf
,MapConf
,Property
,SecurityConfig
,ServerConfig
public interface Conf
AConf
represents an immutable object which can be used for configuring components.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Conf
empty()
Static helper that can be used to creates a new emptyConf
instance.boolean
getBoolean(String path)
Gets a required parameter as an boolean.<T> T
getClass(String path, Class<T> type)
Gets a required parameter as an instances of typeConf
.<T> Collection<T>
getClasses(String path, Class<T> type)
Gets a required parameter as a list of instances of typeConf
.Map<String,Object>
getConfAsMap()
Converts thisConf
into a path-value map.Properties
getConfAsProperties()
Converts thisConf
into a properties.double
getDouble(String path)
Gets a required parameter as a double.int
getInt(String path)
Gets a required parameter as an integer.long
getLong(String path)
Gets a required parameter as a long.default Optional<Boolean>
getOptionalBoolean(String path)
Gets an optional parameter as an boolean.default Optional<Double>
getOptionalDouble(String path)
Gets an optional parameter as an double.default Optional<Integer>
getOptionalInt(String path)
Gets an optional parameter as an integer.default Optional<Long>
getOptionalLong(String path)
Gets an optional parameter as a long.default Optional<String>
getOptionalString(String path)
Gets an optional parameter as a string.String
getString(String path)
Gets a required parameter as a string.List<String>
getStringList(String path)
Gets a required parameter as a list.Conf
getSubConf(String path)
Gets a required parameter as aConf
.List<Conf>
getSubConfList(String path)
Gets a required parameter as a list ofConf
.Object
getValue(String path)
Gets a required parameter value.boolean
hasPath(String path)
Checks whether the specified path exists into thisConf
.Set<String>
keySet()
Returns aSet
view of the keys contained in this conf.static Conf
of(Conf... configurations)
Static helper that can be used to merge multipleConf
instances.static Conf
of(String k1, Object v1)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(String k1, Object v1, String k2, Object v2)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(String k1, Object v1, String k2, Object v2, String k3, Object v3)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.static Conf
of(Collection<? extends Conf> configurations)
Static helper that can be used to merge multipleConf
instances.static Conf
of(Map<String,Object> map)
Conf
withFallback(Conf fallback)
-
-
-
Field Detail
-
EMPTY
static final EmptyConf EMPTY
-
-
Method Detail
-
of
static Conf of(String k1, Object v1)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(String k1, Object v1, String k2, Object v2)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(String k1, Object v1, String k2, Object v2, String k3, Object v3)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(String k1, Object v1, String k2, Object v2, String k3, Object v3, String k4, Object v4, String k5, Object v5, String k6, Object v6)
Static helper that can be used to create a new emptyConf
instance using the specified key-value pair.- Returns:
- a new
Conf
instance.
-
of
static Conf of(Conf... configurations)
Static helper that can be used to merge multipleConf
instances.- Returns:
- a new
Conf
instance.
-
of
static Conf of(Collection<? extends Conf> configurations)
Static helper that can be used to merge multipleConf
instances.- Returns:
- a new
Conf
instance.
-
empty
static Conf empty()
Static helper that can be used to creates a new emptyConf
instance.- Returns:
- a new
Conf
instance.
-
getValue
Object getValue(String path)
Gets a required parameter value.- Parameters:
path
- the parameter path.- Returns:
- the object value.
-
keySet
Set<String> keySet()
Returns aSet
view of the keys contained in this conf.- Returns:
- a set view of the keys contained in this conf
-
getString
String getString(String path)
Gets a required parameter as a string.- Parameters:
path
- the parameter path.- Returns:
- the parameter value as a string.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getOptionalString
default Optional<String> getOptionalString(String path)
Gets an optional parameter as a string.- Parameters:
path
- the parameter path.- Returns:
- the
Optional
value.
-
getLong
long getLong(String path)
Gets a required parameter as a long.- Parameters:
path
- the parameter path.- Returns:
- the parameter value as a long.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getOptionalLong
default Optional<Long> getOptionalLong(String path)
Gets an optional parameter as a long.- Parameters:
path
- the parameter path.- Returns:
- the
Optional
value.
-
getInt
int getInt(String path)
Gets a required parameter as an integer.- Parameters:
path
- the parameter path.- Returns:
- the parameter value as a int.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getOptionalInt
default Optional<Integer> getOptionalInt(String path)
Gets an optional parameter as an integer.- Parameters:
path
- the parameter path.- Returns:
- the
Optional
value.
-
getBoolean
boolean getBoolean(String path)
Gets a required parameter as an boolean.- Parameters:
path
- the parameter path.- Returns:
- the parameter value as a boolean.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getOptionalBoolean
default Optional<Boolean> getOptionalBoolean(String path)
Gets an optional parameter as an boolean.- Parameters:
path
- the parameter path.- Returns:
- the
Optional
value.
-
getDouble
double getDouble(String path)
Gets a required parameter as a double.- Parameters:
path
- the parameter path.- Returns:
- the parameter value as a double.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getOptionalDouble
default Optional<Double> getOptionalDouble(String path)
Gets an optional parameter as an double.- Parameters:
path
- the parameter path.- Returns:
- the
Optional
value.
-
getStringList
List<String> getStringList(String path)
Gets a required parameter as a list.- Parameters:
path
- the parameter path.- Returns:
- a string list value.
- Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getSubConf
Conf getSubConf(String path)
Gets a required parameter as aConf
.- Parameters:
path
- the parameter path.- Returns:
- a new
Conf
instance. - Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getSubConfList
List<Conf> getSubConfList(String path)
Gets a required parameter as a list ofConf
.- Parameters:
path
- the parameter path.- Returns:
- a new list of
Conf
instances. - Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
hasPath
boolean hasPath(String path)
Checks whether the specified path exists into thisConf
.- Parameters:
path
- the path to be checked.- Returns:
true
if the path exists,false
otherwise.
-
getClasses
<T> Collection<T> getClasses(String path, Class<T> type)
Gets a required parameter as a list of instances of typeConf
.- Type Parameters:
T
- the expected type.- Parameters:
path
- the parameter path.type
- the class of the .- Returns:
- a new
Collection
ofConf
. - Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getClass
<T> T getClass(String path, Class<T> type)
Gets a required parameter as an instances of typeConf
.- Type Parameters:
T
- the expected type.- Parameters:
path
- the parameter path.type
- the class of the .- Returns:
- a new
Collection
ofConf
. - Throws:
MissingConfException
- if no parameter can be found for the specified path.
-
getConfAsMap
Map<String,Object> getConfAsMap()
Converts thisConf
into a path-value map.- Returns:
- a new
Map
instance containing the configuration values.
-
getConfAsProperties
Properties getConfAsProperties()
Converts thisConf
into a properties.- Returns:
- a new
Properties
instance containing the configuration values.
-
-