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