Class ValueWidening

java.lang.Object
com.aquima.interactions.expressions.semantics.ValueWidening

public final class ValueWidening extends Object
Utility class to implement widening behavior for values. Widening between types is allowed when there is no loss of precision, according to the following rules:
 1. integer -> number, percentage, currency and string.
 2. number -> percentage and currency.
 3. percentage -> number
 4. currency -> number
 
  • Method Details

    • getWidenedValue

      public static IValue getWidenedValue(IValue value, DataType type)
      Derives a new value that has been widened to the requested data type, if the value can be widened to that type. null is returned if the widening operation is not allowed.
      Parameters:
      value - The value to widen.
      type - The data type to widen to.
      Returns:
      The widened value if widening is allowed, null otherwise.
    • getWidenedValue

      public static IPrimitiveValue getWidenedValue(IPrimitiveValue value, DataType type)
      Derives a new value that has been widened to the requested data type, if the value can be widened to that type. null is returned if the widening operation is not allowed.
      Parameters:
      value - The primitive value to widen.
      type - The data type to widen to.
      Returns:
      The widened value if widening is allowed, null otherwise.