Class ValueWidening
java.lang.Object
com.aquima.interactions.expressions.semantics.ValueWidening
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 Summary
Modifier and TypeMethodDescriptionstatic 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.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.
-
Method Details
-
getWidenedValue
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
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.
-