Config

public interface Config
Author:Lars Kroll <lkroll@kth.se>

Methods

copy

public Config copy(boolean newVersionLine)

getValue

public <T> T getValue(String key, Class<T> type)

Return the value at key as T or null 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:
Returns:

The value as T if present or null otherwise

getValueOrDefault

public <T extends Object> T getValueOrDefault(String key, T defaultValue)

Return the value at key as T or defaultValue 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 or defaultValue 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. Use getValues(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}

modify

public Builder modify(UUID author)

readValue

public <T> Optional<T> readValue(String key)

Returns an Optional of the value at key as T or Absent<T> if none.

Does not perform checked casting!

Parameters:
  • <T> – The requested type of the value
  • key – The location of the value
Returns:

Optional.of(T) if present or Absent<T> otherwise

readValue

public <T> Optional<T> readValue(String key, Class<T> type)

Returns an Optional of the value at key as T or Absent<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 or Absent<T> otherwise