Class ParameterConfigurer<T>

  • Type Parameters:
    T - the type of the parameter
    All Implemented Interfaces:
    ValueConfigurer<T>

    public class ParameterConfigurer<T>
    extends java.lang.Object
    implements ValueConfigurer<T>
    A parameter configurer for a parameter, including a type translator from JSON, a ValueConfigurer for setting the value and an Supplier to obtain the parameter value for failure recovery.
    Author:
    Holger Eichelberger, SSE
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private ValueConfigurer<T> cfg  
      private java.lang.Class<T> cls  
      private java.util.function.Supplier<T> getter  
      private java.lang.String name  
      private java.lang.String sysProperty  
      private de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator  
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
        ParameterConfigurer​(java.lang.String name, java.lang.Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator, ValueConfigurer<T> cfg)
      Creates a parameter configurer without getter, i.e., implicitly recovery is disabled.
      protected ParameterConfigurer​(java.lang.String name, java.lang.Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator, ValueConfigurer<T> cfg, java.util.function.Supplier<T> getter)
      Creates a parameter configurer without getter, i.e., implicitly recovery is disabled.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addValue​(java.util.Map<java.lang.String,​java.lang.String> values, java.lang.Object value)
      Adds the string representation of value to values in terms of the parameter represented by this configurer.
      void configure​(T value)
      Configures the parameter with the given value.
      java.util.function.Supplier<T> getGetter()
      Returns the value getter.
      java.lang.String getName()
      Returns the name of the parameter.
      de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> getTranslator()
      Returns the type translator to be used for this parameter.
      java.lang.Class<T> getType()
      Returns the type of the parameter.
      ParameterConfigurer<T> withSystemProperty​(java.lang.String sysProperty)
      Optional system property that shall be considered during initialization.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • name

        private java.lang.String name
      • translator

        private de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator
      • getter

        private java.util.function.Supplier<T> getter
      • cls

        private java.lang.Class<T> cls
      • sysProperty

        private java.lang.String sysProperty
    • Constructor Detail

      • ParameterConfigurer

        public ParameterConfigurer​(java.lang.String name,
                                   java.lang.Class<T> cls,
                                   de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator,
                                   ValueConfigurer<T> cfg)
        Creates a parameter configurer without getter, i.e., implicitly recovery is disabled.
        Parameters:
        name - the name of the parameter
        cls - the class representing the type
        translator - the type translator
        cfg - the parameter value configurer
      • ParameterConfigurer

        protected ParameterConfigurer​(java.lang.String name,
                                      java.lang.Class<T> cls,
                                      de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> translator,
                                      ValueConfigurer<T> cfg,
                                      java.util.function.Supplier<T> getter)
        Creates a parameter configurer without getter, i.e., implicitly recovery is disabled.
        Parameters:
        name - the name of the parameter
        cls - the class representing the type
        translator - the type translator
        cfg - the parameter value configurer
        getter - a function returning the actual value of the parameter, used for recovery, may be null for disabling recovery on this parameter
    • Method Detail

      • withSystemProperty

        public ParameterConfigurer<T> withSystemProperty​(java.lang.String sysProperty)
        Optional system property that shall be considered during initialization.
        Parameters:
        sysProperty - system property name that shall be used via translator to initialize the parameter, takes precedence
        Returns:
        this (builder style)
      • configure

        public void configure​(T value)
                       throws java.util.concurrent.ExecutionException
        Description copied from interface: ValueConfigurer
        Configures the parameter with the given value.
        Specified by:
        configure in interface ValueConfigurer<T>
        Parameters:
        value - the value to use
        Throws:
        java.util.concurrent.ExecutionException - if configuring the value fails for some reason
      • getTranslator

        public de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,​T> getTranslator()
        Returns the type translator to be used for this parameter.
        Returns:
        the type translator
      • getGetter

        public java.util.function.Supplier<T> getGetter()
        Returns the value getter.
        Returns:
        the getter, may be null
      • getName

        public java.lang.String getName()
        Returns the name of the parameter.
        Returns:
        the name
      • getType

        public java.lang.Class<T> getType()
        Returns the type of the parameter.
        Returns:
        the type
      • addValue

        public void addValue​(java.util.Map<java.lang.String,​java.lang.String> values,
                             java.lang.Object value)
        Adds the string representation of value to values in terms of the parameter represented by this configurer. Any problem/error will be logged rather than thrown.
        Parameters:
        values - the values to be modified as a side effect
        value - the value to be added