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>
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 -
Constructor Summary
ConstructorsConstructorDescriptionParameterConfigurer(String name, Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<String, T> translator, ValueConfigurer<T> cfg) Creates a parameter configurer without getter, i.e., implicitly recovery is disabled.ParameterConfigurer(String name, Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<String, T> translator, ValueConfigurer<T> cfg, Supplier<T> getter) Creates a parameter configurer without getter, i.e., implicitly recovery is disabled. -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the string representation ofvaluetovaluesin terms of the parameter represented by this configurer.voidConfigures the parameter with the given value.Returns the value getter.getName()Returns the name of the parameter.Returns the type translator to be used for this parameter.getType()Returns the type of the parameter.private ObjectgetValueFromSysProperty(Object value) Returns the object value determined from the attached system property.withSystemProperty(String sysProperty) Optional system property that shall be considered during initialization.
-
Field Details
-
name
-
translator
-
cfg
-
getter
-
cls
-
sysProperty
-
-
Constructor Details
-
ParameterConfigurer
public ParameterConfigurer(String name, Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<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
public ParameterConfigurer(String name, Class<T> cls, de.iip_ecosphere.platform.transport.serialization.TypeTranslator<String, T> translator, ValueConfigurer<T> cfg, 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 Details
-
withSystemProperty
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
Description copied from interface:ValueConfigurerConfigures the parameter with the given value.- Specified by:
configurein interfaceValueConfigurer<T>- Parameters:
value- the value to use- Throws:
ExecutionException- if configuring the value fails for some reason
-
getTranslator
Returns the type translator to be used for this parameter.- Returns:
- the type translator
-
getGetter
Returns the value getter.- Returns:
- the getter, may be null
-
getName
Returns the name of the parameter.- Returns:
- the name
-
getType
Returns the type of the parameter.- Returns:
- the type
-
addValue
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
-
getValueFromSysProperty
Returns the object value determined from the attached system property.- Parameters:
value- initial value, may be null- Returns:
- the value if there is a system property and it can be converted/translated,
valueelse
-