use of io.atlasmap.v2.MassUnitType in project atlasmap by atlasmap.
the class NumberFieldActions method convertMassUnit.
@AtlasFieldActionInfo(name = "ConvertMassUnit", sourceType = FieldType.NUMBER, targetType = FieldType.NUMBER, sourceCollectionType = CollectionType.NONE, targetCollectionType = CollectionType.NONE)
public static Number convertMassUnit(Action action, Number input) {
if (input == null) {
return 0;
}
if (action == null || !(action instanceof ConvertMassUnit) || ((ConvertMassUnit) action).getFromUnit() == null || ((ConvertMassUnit) action).getToUnit() == null) {
throw new IllegalArgumentException("ConvertMassUnit must be specfied with fromUnit and toUnit");
}
MassUnitType fromUnit = ((ConvertMassUnit) action).getFromUnit();
MassUnitType toUnit = ((ConvertMassUnit) action).getToUnit();
double rate = massConvertionTable.get(fromUnit).get(toUnit);
return doMultiply(input, rate);
}
Aggregations