Package se.sics.kompics.config
Class Config.Builder
java.lang.Object
se.sics.kompics.config.Config.Builder
- All Implemented Interfaces:
Config
- Enclosing interface:
- Config
public static class Config.Builder extends Object implements Config
-
Nested Class Summary
Nested classes/interfaces inherited from interface se.sics.kompics.config.Config
Config.Builder, Config.Factory, Config.Impl
-
Method Summary
Modifier and Type Method Description void
addValue(String key, Object o)
Addso
to the collection atkey
.void
addValues(String key, Collection<Object> os)
Adds all values ino
to the collection atkey
.Config
copy(boolean newVersionLine)
ConfigUpdate
finalise()
<T> T
getValue(String key, Class<T> type)
Return the value atkey
asT
ornull
if none.<T> T
getValueOrDefault(String key, T defaultValue)
Return the value atkey
asT
ordefaultValue
if none.<T> List<T>
getValues(String key)
Returns a list of values at @{code key}.<T> List<T>
getValues(String key, Class<T> type)
Returns a list of values at @{code key}.Config.Builder
modify(UUID author)
<T> Optional<T>
readValue(String key)
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.<T> Optional<T>
readValue(String key, Class<T> type)
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.void
setValue(String key, Object o)
Sets the value atkey
too
.void
setValue(String key, Object o, ValueOptions opts)
Sets the value atkey
too
.
-
Method Details
-
readValue
Description copied from interface:Config
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.Does not perform checked casting!
-
readValue
Description copied from interface:Config
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.Performs checked casting against
type
. -
getValue
Description copied from interface:Config
Return the value atkey
asT
ornull
if none.Performs checked casting against
type
.- Specified by:
getValue
in interfaceConfig
- Type Parameters:
T
- The requested type of the value- Parameters:
key
- The location of the valuetype
- The type to cast the value to- Returns:
- The value as
T
if present ornull
otherwise - Throws:
ClassCastException
- if the value can not be cast totype
-
getValueOrDefault
Description copied from interface:Config
Return the value atkey
asT
ordefaultValue
if none.Performs checked casting against the type of
defaultValue
.- Specified by:
getValueOrDefault
in interfaceConfig
- Type Parameters:
T
- The requested type of the value- Parameters:
key
- The location of the valuedefaultValue
- Returned if there is not value of the right type atkey
- Returns:
- The value as
T
if present ordefaultValue
otherwise
-
modify
-
getValues
Description copied from interface:Config
Returns a list of values at @{code key}.The casts to
T
are unchecked in this method. UseConfig.getValues(java.lang.String, java.lang.Class)
if you don't want this behaviour. -
getValues
Description copied from interface:Config
Returns a list of values at @{code key}.Value casts are checked against
type
. May throw a @{link se.sics.kompics.config.ConfigValueException } if a value can't be cast. -
setValue
- Parameters:
key
- The location of the targeto
- The new value of the target
-
setValue
Sets the value atkey
too
.- Parameters:
key
- The location of the targeto
- The new value of the targetopts
- The options associated with the new value
-
addValue
Addso
to the collection atkey
.Starts a new collection if the value doesn't exists or the value isn't currently a collection.
- Parameters:
key
- The location of the target collectiono
- The value to add to the target collection
-
addValues
Adds all values ino
to the collection atkey
.Starts a new collection if the value doesn't exists or the value isn't currently a collection.
- Parameters:
key
- The location of the target collectionos
- The collection of values to add to the target collection
-
finalise
-
copy
-