Class ParameterTransformer

java.lang.Object
org.mule.extensions.java.internal.transformer.ParameterTransformer

public class ParameterTransformer extends Object
This class purpose is checking and transforming objects to a parameter type of a certain Executable When transforming an input into something that fits to an Executable's parameter, this class will make a best effort in order to make this transformation possible. In case that the transformation requires to transform a Collection or Map, a new instance will be created for it.
Since:
1.1
  • Constructor Details

    • ParameterTransformer

      public ParameterTransformer(Executable executable, org.mule.runtime.api.transformation.TransformationService transformationService, org.mule.runtime.core.api.el.ExpressionManager expressionManager)
      Parameters:
      executable - The executable whose parameters will be checked against Objects.
      transformationService - An instance of a TransformationService use to tranform parameters.
      expressionManager - An instance of a ExpressionManager used to execute DataWeave expressions.
  • Method Details

    • parameterNeedsTransformation

      public boolean parameterNeedsTransformation(Object value, int parameterIndex)
      Method that allows to check if a value fits a certain argument of the executable. Generic values will only be checked for Map and Collection values.
      Parameters:
      value - The value which type will be checked.
      parameterIndex - The index of the parameter in the executable arguments.
      Returns:
      whether the value needs to be transformed in order to fit the parameter from the executable
    • transformParameter

      public Optional<Object> transformParameter(Object value, int parameterIndex)
      Method that makes a best efford to map an object to the type of a parameter of the excecutable. Map and Collection will be replaced with new instances. Other object will remain the same instance if they do not need to be transformed. For example, if a list is transformed, a new list will be created and will contain the same instances from the former list that did not needed to be transformed and new instances for the ones being transformed.
      Parameters:
      value - The value that will be transformed.
      parameterIndex - The index of the parameter in the executable arguments.
      Returns:
      The value transformed to fit the executable parameter.