Search in sources :

Example 1 with AreaUnitType

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);
}
Also used : ConvertAreaUnit(io.atlasmap.v2.ConvertAreaUnit) AreaUnitType(io.atlasmap.v2.AreaUnitType) AtlasFieldActionInfo(io.atlasmap.spi.AtlasFieldActionInfo)

Aggregations

AtlasFieldActionInfo (io.atlasmap.spi.AtlasFieldActionInfo)1 AreaUnitType (io.atlasmap.v2.AreaUnitType)1 ConvertAreaUnit (io.atlasmap.v2.ConvertAreaUnit)1