Class TransformationManager

java.lang.Object
software.amazon.lambda.powertools.parameters.transform.TransformationManager

public class TransformationManager extends Object
Manager in charge of transforming parameter values in another format.
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 Details

    • TransformationManager

      public TransformationManager()
  • Method Details

    • setTransformer

      public void setTransformer(Class<? extends Transformer> transformerClass)
      Set the Transformer to use for transformation. Must be called before any transformation.
      Parameters:
      transformerClass - class of the Transformer
    • unsetTransformer

      public void unsetTransformer()
      Unset the Transformer and clean up thread-local storage. Should be called after transformation is complete to prevent memory leaks.
    • shouldTransform

      public boolean shouldTransform()
      Returns:
      true if a Transformer has been passed to the Manager
    • performBasicTransformation

      public String performBasicTransformation(String value)
      Transform a String in another String. Must be used with a BasicTransformer.
      Parameters:
      value - the value to transform
      Returns:
      the value transformed
    • performComplexTransformation

      public <T> T performComplexTransformation(String value, Class<T> targetClass)
      Transform a String in a Java Object.
      Parameters:
      value - the value to transform
      targetClass - the type of the target object.
      Returns:
      the value transformed in an object ot type T.