Class TransformationManager
java.lang.Object
software.amazon.lambda.powertools.parameters.transform.TransformationManager
Manager in charge of transforming parameter values in another format.
Leverages a
The transformer must be passed with
Leverages a
Transformer in order to perform the transformation. The transformer must be passed with
setTransformer(Class) before performing any transform operation.
This class is thread-safe. Transformer configuration is thread-local to support concurrent requests with different transformation requirements.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionperformBasicTransformation(String value) Transform a String in another String.<T> TperformComplexTransformation(String value, Class<T> targetClass) Transform a String in a Java Object.voidsetTransformer(Class<? extends Transformer> transformerClass) Set theTransformerto use for transformation.booleanvoidUnset theTransformerand clean up thread-local storage.
-
Constructor Details
-
TransformationManager
public TransformationManager()
-
-
Method Details
-
setTransformer
Set theTransformerto use for transformation. Must be called before any transformation.- Parameters:
transformerClass- class of theTransformer
-
unsetTransformer
public void unsetTransformer()Unset theTransformerand clean up thread-local storage. Should be called after transformation is complete to prevent memory leaks. -
shouldTransform
public boolean shouldTransform()- Returns:
- true if a
Transformerhas been passed to the Manager
-
performBasicTransformation
Transform a String in another String. Must be used with aBasicTransformer.- Parameters:
value- the value to transform- Returns:
- the value transformed
-
performComplexTransformation
Transform a String in a Java Object.- Parameters:
value- the value to transformtargetClass- the type of the target object.- Returns:
- the value transformed in an object ot type T.
-