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