Class Configuration

java.lang.Object
org.meeuw.configuration.Configuration
All Implemented Interfaces:
Iterable<ConfigurationAspect>

public class Configuration extends Object implements Iterable<ConfigurationAspect>
Immutable object containing all ConfigurationAspects.
Since:
0.4
Author:
Michiel Meeuwissen
  • Method Details

    • getAspect

      public <E extends ConfigurationAspect> E getAspect(Class<E> clazz)
      Returns the aspect with given class.
      Type Parameters:
      E - the type of the configuration aspect
      Parameters:
      clazz - the class of the configuration aspect
      Returns:
      the configuration aspect instance of that class currently configured in this configuration object
    • getAspectValue

      public <E extends ConfigurationAspect, V> V getAspectValue(Class<E> clazz, Function<E,V> getter)
      Gets a value of a certain configuration aspect
      Type Parameters:
      E - the type of the configuration aspect
      V - the type of the configuration aspect value
      Parameters:
      clazz - the class of the configuration aspect
      getter - a function to get the value from the instance of the aspect (probably a method reference)
      Returns:
      the request configuration aspect value
    • with

      public <E extends ConfigurationAspect> Configuration with(Class<E> clazz, UnaryOperator<E> config)
      Type Parameters:
      E - the type of the class
      Parameters:
      clazz - The configuration aspect class
      config - The operator that given the exising value for the aspect, produces a new one
      Returns:
      a new Configuration with a changed ConfigurationAspect
    • getConfigurationAspectsAssociatedWith

      public List<ConfigurationAspect> getConfigurationAspectsAssociatedWith(Class<?> clazz)
    • toBuilder

      public Configuration.Builder toBuilder()
      Converts this configuration into a new Configuration.Builder, so it can be converted to a new configuration set.
    • builder

      public static Configuration.Builder builder()
      Returns:
      returns a new Configuration.Builder to assemble a new configuration
    • iterator

      public Iterator<ConfigurationAspect> iterator()
      Specified by:
      iterator in interface Iterable<ConfigurationAspect>