@Test public void testConvertAreaUnit() { ConvertAreaUnit action = new ConvertAreaUnit(); action.setFromUnit(AreaUnitType.SQUARE_METER); action.setToUnit(AreaUnitType.SQUARE_METER); assertEquals(1.0, NumberFieldActions.convertAreaUnit(action, 1.0)); action.setToUnit(AreaUnitType.SQUARE_FOOT); assertEquals(21.527820833419447, NumberFieldActions.convertAreaUnit(action, 2.0)); action.setToUnit(AreaUnitType.SQUARE_MILE); assertEquals(1.1583064756273378, NumberFieldActions.convertAreaUnit(action, 3000000.0)); action.setFromUnit(AreaUnitType.SQUARE_FOOT); action.setToUnit(AreaUnitType.SQUARE_METER); assertEquals(3.7161215999999997, NumberFieldActions.convertAreaUnit(action, 40.0)); action.setToUnit(AreaUnitType.SQUARE_FOOT); assertEquals(5.0, NumberFieldActions.convertAreaUnit(action, 5.0)); action.setToUnit(AreaUnitType.SQUARE_MILE); assertEquals(2.1522038567493116, NumberFieldActions.convertAreaUnit(action, 60000000.0)); action.setFromUnit(AreaUnitType.SQUARE_MILE); action.setToUnit(AreaUnitType.SQUARE_METER); assertEquals(18129916.772352, NumberFieldActions.convertAreaUnit(action, 7.0)); action.setToUnit(AreaUnitType.SQUARE_FOOT); assertEquals(223027200.0, NumberFieldActions.convertAreaUnit(action, 8.0)); action.setToUnit(AreaUnitType.SQUARE_MILE); assertEquals(9.0, NumberFieldActions.convertAreaUnit(action, 9.0)); assertNotNull(NumberFieldActions.convertAreaUnit(action, new BigDecimal("9"))); }
@AtlasActionProcessor public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) { if (input == null) { return 0; } if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit"); } AreaUnitType fromUnit = convertAreaUnit.getFromUnit(); AreaUnitType toUnit = convertAreaUnit.getToUnit(); double rate = areaConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) { if (input == null) { return 0; } if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit"); } AreaUnitType fromUnit = convertAreaUnit.getFromUnit(); AreaUnitType toUnit = convertAreaUnit.getToUnit(); double rate = areaConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) { if (input == null) { return 0; } if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit"); } AreaUnitType fromUnit = convertAreaUnit.getFromUnit(); AreaUnitType toUnit = convertAreaUnit.getToUnit(); double rate = areaConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) { if (input == null) { return 0; } if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit"); } AreaUnitType fromUnit = convertAreaUnit.getFromUnit(); AreaUnitType toUnit = convertAreaUnit.getToUnit(); double rate = areaConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }  @AtlasActionProcessor static Number absoluteValue(AbsoluteValue action, Number input); @AtlasActionProcessor static Number add(Add action, List<Number> inputs); @AtlasActionProcessor static Number average(Average action, List<Number> inputs); @AtlasActionProcessor static Number ceiling(Ceiling action, Number input); @AtlasActionProcessor static Number convertMassUnit(ConvertMassUnit convertMassUnit, Number input); @AtlasActionProcessor static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input); @AtlasActionProcessor static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input); @AtlasActionProcessor static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input); @AtlasActionProcessor static Number divide(Divide divide, List<Number> inputs); @AtlasActionProcessor static Number floor(Floor floor, Number input); @AtlasActionProcessor static Number maximum(Maximum maximum, List<Number> inputs); @AtlasActionProcessor static Number minimum(Minimum minimum, List<Number> inputs); @AtlasActionProcessor static Number multiply(Multiply multiply, List<Number> inputs); @AtlasActionProcessor static Number round(Round action, Number input); @AtlasActionProcessor static Number subtract(Subtract subtract, List<Number> inputs); }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input) { if (input == null) { return 0; } if (convertAreaUnit == null || convertAreaUnit.getFromUnit() == null || convertAreaUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertAreaUnit must be specified with fromUnit and toUnit"); } AreaUnitType fromUnit = convertAreaUnit.getFromUnit(); AreaUnitType toUnit = convertAreaUnit.getToUnit(); double rate = areaConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }  @AtlasActionProcessor static Number absoluteValue(AbsoluteValue action, Number input); @AtlasActionProcessor static Number add(Add action, List<Number> inputs); @AtlasActionProcessor static Number average(Average action, List<Number> inputs); @AtlasActionProcessor static Number ceiling(Ceiling action, Number input); @AtlasActionProcessor static Number convertMassUnit(ConvertMassUnit convertMassUnit, Number input); @AtlasActionProcessor static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input); @AtlasActionProcessor static Number convertAreaUnit(ConvertAreaUnit convertAreaUnit, Number input); @AtlasActionProcessor static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input); @AtlasActionProcessor static Number divide(Divide divide, List<Number> inputs); @AtlasActionProcessor static Number floor(Floor floor, Number input); @AtlasActionProcessor static Number maximum(Maximum maximum, List<Number> inputs); @AtlasActionProcessor static Number minimum(Minimum minimum, List<Number> inputs); @AtlasActionProcessor static Number multiply(Multiply multiply, List<Number> inputs); @AtlasActionProcessor static Number round(Round action, Number input); @AtlasActionProcessor static Number subtract(Subtract subtract, List<Number> inputs);  }