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