Class NumberToComplexDecorator

java.lang.Object
com.singularsys.extensions.field.implementations.FieldDecorator
com.singularsys.extensions.field.implementations.NumberToComplexDecorator
All Implemented Interfaces:
FieldI, IntegerConvertor, Serializable

public class NumberToComplexDecorator extends FieldDecorator
Convert all Number types to Complex, and optionally convert result to Doubles if possible. By default, results will always be complex, but if the simplifyResults is set in the constructor real results will be converted to Doubles.
See Also:
  • Constructor Details

    • NumberToComplexDecorator

      public NumberToComplexDecorator(FieldI field)
      Constructor, does not simplify results.
      Parameters:
      field - base field
    • NumberToComplexDecorator

      public NumberToComplexDecorator(FieldI field, boolean simplifyResults)
      If simplifyResults is true, any complex result that represent a real numbers will be converted back to a double.
      Parameters:
      field - base field
      simplifyResults - whether to try to convert real results back to Doubles.
  • Method Details

    • convertInput

      public Object convertInput(Object in)
      Description copied from class: FieldDecorator
      Attempt to convert the input to a Field method.
      Specified by:
      convertInput in class FieldDecorator
      Parameters:
      in -
      Returns:
      If appropriate convert in to a different type, otherwise return in.
    • convertOutput

      public Object convertOutput(Object out)
      Description copied from class: FieldDecorator
      Attempt to convert the output from a Field method.
      Specified by:
      convertOutput in class FieldDecorator
      Parameters:
      out -
      Returns:
      If appropriate convert out to a different type, otherwise return out.