Package se.sics.kompics.config
Interface Config
- All Known Implementing Classes:
Config.Builder
,Config.Impl
public interface Config
A Kompics configuration.
Basically a versioned, in-memory key-value store with some implicit type coercions (Converter
).
- Author:
- Lars Kroll <[email protected]>
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Config.Builder
static class
Config.Factory
static class
Config.Impl
-
Method Summary
Modifier and Type Method Description Config
copy(boolean newVersionLine)
<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.
-
Method Details
-
readValue
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.Does not perform checked casting!
- Type Parameters:
T
- The requested type of the value- Parameters:
key
- The location of the value- Returns:
Optional.of(T)
if present orAbsent<T>
otherwise
-
readValue
Returns anOptional
of the value atkey
asT
orAbsent<T>
if none.Performs checked casting against
type
.- Type Parameters:
T
- The requested type of the value- Parameters:
key
- The location of the valuetype
- The type to cast the value to- Returns:
Optional.of(T)
if present orAbsent<T>
otherwise
-
getValue
Return the value atkey
asT
ornull
if none.Performs checked casting against
type
.- 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
Return the value atkey
asT
ordefaultValue
if none.Performs checked casting against the type of
defaultValue
.- 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
-
getValues
Returns a list of values at @{code key}.The casts to
T
are unchecked in this method. UsegetValues(java.lang.String, java.lang.Class)
if you don't want this behaviour.- Type Parameters:
T
- The list value type- Parameters:
key
- The location of the values- Returns:
- A list of values at @{code key}
-
getValues
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.- Type Parameters:
T
- The list value type- Parameters:
key
- The location of the valuestype
- The type to cast the values to- Returns:
- A list of values at @{code key}
-
modify
-
copy
-