Config¶
-
public interface
Config
¶ Author: Lars Kroll <lkroll@kth.se>
Methods¶
getValue¶
-
public <T> T
getValue
(String key, Class<T> type)¶ Return the value at
key
asT
ornull
if none.Performs checked casting against
type
.Parameters: - <T> – The requested type of the value
- key – The location of the value
- type – The type to cast the value to
Throws: - ClassCastException – if the value can not be cast to
type
Returns: The value as
T
if present ornull
otherwise
getValueOrDefault¶
-
public <T extends Object> T
getValueOrDefault
(String key, T defaultValue)¶ Return the value at
key
asT
ordefaultValue
if none.Performs checked casting against the type of
defaultValue
.Parameters: - <T> – The requested type of the value
- key – The location of the value
- defaultValue – Returned if there is not value of the right type at
key
Returns: The value as
T
if present ordefaultValue
otherwise
getValues¶
-
public <T> List<T>
getValues
(String key)¶ 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.Parameters: - <T> – The list value type
- key – The location of the values
Returns: A list of values at @{code key}
getValues¶
-
public <T> List<T>
getValues
(String key, Class<T> type)¶ 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.Parameters: - <T> – The list value type
- key – The location of the values
- type – The type to cast the values to
Returns: A list of values at @{code key}
readValue¶
readValue¶
-
public <T> Optional<T>
readValue
(String key, Class<T> type)¶ Returns an
Optional
of the value atkey
asT
orAbsent<T>
if none.Performs checked casting against
type
.Parameters: - <T> – The requested type of the value
- key – The location of the value
- type – The type to cast the value to
Returns: Optional.of(T)
if present orAbsent<T>
otherwise