Class Config.Impl

java.lang.Object
se.sics.kompics.config.Config.Impl
All Implemented Interfaces:
Config
Enclosing interface:
Config

public static class Config.Impl
extends Object
implements Config
  • Method Details

    • readValue

      public <T> Optional<T> readValue​(String key)
      Description copied from interface: Config
      Returns an Optional of the value at key as T or Absent<T> if none.

      Does not perform checked casting!

      Specified by:
      readValue in interface Config
      Type Parameters:
      T - The requested type of the value
      Parameters:
      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)
      Description copied from interface: Config
      Returns an Optional of the value at key as T or Absent<T> if none.

      Performs checked casting against type.

      Specified by:
      readValue in interface Config
      Type Parameters:
      T - The requested type of the value
      Parameters:
      key - The location of the value
      type - The type to cast the value to
      Returns:
      Optional.of(T) if present or Absent<T> otherwise
    • getValue

      public <T> T getValue​(String key, Class<T> type) throws ClassCastException
      Description copied from interface: Config
      Return the value at key as T or null if none.

      Performs checked casting against type.

      Specified by:
      getValue in interface Config
      Type Parameters:
      T - The requested type of the value
      Parameters:
      key - The location of the value
      type - The type to cast the value to
      Returns:
      The value as T if present or null otherwise
      Throws:
      ClassCastException - if the value can not be cast to type
    • getValueOrDefault

      public <T> T getValueOrDefault​(String key, T defaultValue)
      Description copied from interface: Config
      Return the value at key as T or defaultValue if none.

      Performs checked casting against the type of defaultValue.

      Specified by:
      getValueOrDefault in interface Config
      Type Parameters:
      T - The requested type of the value
      Parameters:
      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
    • modify

      public Config.Builder modify​(UUID author)
      Specified by:
      modify in interface Config
    • getValues

      public <T> List<T> getValues​(String key)
      Description copied from interface: Config
      Returns a list of values at @{code key}.

      The casts to T are unchecked in this method. Use Config.getValues(java.lang.String, java.lang.Class) if you don't want this behaviour.

      Specified by:
      getValues in interface Config
      Type Parameters:
      T - The list value type
      Parameters:
      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)
      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.

      Specified by:
      getValues in interface Config
      Type Parameters:
      T - The list value type
      Parameters:
      key - The location of the values
      type - The type to cast the values to
      Returns:
      A list of values at @{code key}
    • copy

      public Config copy​(boolean newVersionLine)
      Specified by:
      copy in interface Config
    • apply

      public void apply​(ConfigUpdate update, Optional<ValueMerger> customMergeLogic)