Class ParameterConfigurer<T>
- java.lang.Object
-
- de.iip_ecosphere.platform.services.environment.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, aValueConfigurerfor setting the value and anSupplierto obtain the parameter value for failure recovery.- Author:
- Holger Eichelberger, SSE
-
-
Field Summary
Fields Modifier and Type Field Description private ValueConfigurer<T>cfgprivate java.lang.Class<T>clsprivate java.util.function.Supplier<T>getterprivate java.lang.Stringnameprivate java.lang.StringsysPropertyprivate 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.protectedParameterConfigurer(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 voidaddValue(java.util.Map<java.lang.String,java.lang.String> values, java.lang.Object value)Adds the string representation ofvaluetovaluesin terms of the parameter represented by this configurer.voidconfigure(T value)Configures the parameter with the given value.java.util.function.Supplier<T>getGetter()Returns the value getter.java.lang.StringgetName()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.
-
-
-
Field Detail
-
name
private java.lang.String name
-
translator
private de.iip_ecosphere.platform.transport.serialization.TypeTranslator<java.lang.String,T> translator
-
cfg
private ValueConfigurer<T> cfg
-
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 parametercls- the class representing the typetranslator- the type translatorcfg- 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 parametercls- the class representing the typetranslator- the type translatorcfg- the parameter value configurergetter- 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 viatranslatorto initialize the parameter, takes precedence- Returns:
- this (builder style)
-
configure
public void configure(T value) throws java.util.concurrent.ExecutionException
Description copied from interface:ValueConfigurerConfigures the parameter with the given value.- Specified by:
configurein interfaceValueConfigurer<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 ofvaluetovaluesin 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 effectvalue- the value to be added
-
-