@Test public void testConvertDistanceUnit() { ConvertDistanceUnit action = new ConvertDistanceUnit(); action.setFromUnit(DistanceUnitType.METER_M); action.setToUnit(DistanceUnitType.METER_M); assertEquals(1.0, NumberFieldActions.convertDistanceUnit(action, 1.0)); action.setToUnit(DistanceUnitType.FOOT_FT); assertEquals(6.561679790026247, NumberFieldActions.convertDistanceUnit(action, 2.0)); action.setToUnit(DistanceUnitType.YARD_YD); assertEquals(3.2808398950131235, NumberFieldActions.convertDistanceUnit(action, 3.0)); action.setToUnit(DistanceUnitType.MILE_MI); assertEquals(2.4854847689493362, NumberFieldActions.convertDistanceUnit(action, 4000.0)); action.setToUnit(DistanceUnitType.INCH_IN); assertEquals(196.8503937007874, NumberFieldActions.convertDistanceUnit(action, 5.0)); action.setFromUnit(DistanceUnitType.FOOT_FT); action.setToUnit(DistanceUnitType.METER_M); assertEquals(1.8287999999999998, NumberFieldActions.convertDistanceUnit(action, 6.0)); action.setToUnit(DistanceUnitType.FOOT_FT); assertEquals(7.0, NumberFieldActions.convertDistanceUnit(action, 7.0)); action.setToUnit(DistanceUnitType.YARD_YD); assertEquals(27.0, NumberFieldActions.convertDistanceUnit(action, 81.0)); action.setToUnit(DistanceUnitType.MILE_MI); assertEquals(1.7045454545454546, NumberFieldActions.convertDistanceUnit(action, 9000.0)); action.setToUnit(DistanceUnitType.INCH_IN); assertEquals(12.0, NumberFieldActions.convertDistanceUnit(action, 1.0)); action.setFromUnit(DistanceUnitType.YARD_YD); action.setToUnit(DistanceUnitType.METER_M); assertEquals(22.86, NumberFieldActions.convertDistanceUnit(action, 25.0)); action.setToUnit(DistanceUnitType.FOOT_FT); assertEquals(9.0, NumberFieldActions.convertDistanceUnit(action, 3.0)); action.setToUnit(DistanceUnitType.YARD_YD); assertEquals(4.0, NumberFieldActions.convertDistanceUnit(action, 4.0)); action.setToUnit(DistanceUnitType.MILE_MI); assertEquals(2.840909090909091, NumberFieldActions.convertDistanceUnit(action, 5000.0)); action.setToUnit(DistanceUnitType.INCH_IN); assertEquals(216.0, NumberFieldActions.convertDistanceUnit(action, 6.0)); action.setFromUnit(DistanceUnitType.MILE_MI); action.setToUnit(DistanceUnitType.METER_M); assertEquals(11265.408, NumberFieldActions.convertDistanceUnit(action, 7.0)); action.setToUnit(DistanceUnitType.FOOT_FT); assertEquals(42240.0, NumberFieldActions.convertDistanceUnit(action, 8.0)); action.setToUnit(DistanceUnitType.YARD_YD); assertEquals(15840.0, NumberFieldActions.convertDistanceUnit(action, 9.0)); action.setToUnit(DistanceUnitType.MILE_MI); assertEquals(1.0, NumberFieldActions.convertDistanceUnit(action, 1.0)); action.setToUnit(DistanceUnitType.INCH_IN); assertEquals(126720.0, NumberFieldActions.convertDistanceUnit(action, 2.0)); action.setFromUnit(DistanceUnitType.INCH_IN); action.setToUnit(DistanceUnitType.METER_M); assertEquals(7.62, NumberFieldActions.convertDistanceUnit(action, 300.0)); action.setToUnit(DistanceUnitType.FOOT_FT); assertEquals(3.5, NumberFieldActions.convertDistanceUnit(action, 42.0)); action.setToUnit(DistanceUnitType.YARD_YD); assertEquals(1.5, NumberFieldActions.convertDistanceUnit(action, 54.0)); action.setToUnit(DistanceUnitType.MILE_MI); assertEquals(9.469696969696969, NumberFieldActions.convertDistanceUnit(action, 600000.0)); action.setToUnit(DistanceUnitType.INCH_IN); assertEquals(6.0, NumberFieldActions.convertDistanceUnit(action, 6.0)); }
@AtlasActionProcessor public static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) { if (input == null) { return 0; } if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit"); } DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit(); DistanceUnitType toUnit = convertDistanceUnit.getToUnit(); double rate = distanceConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) { if (input == null) { return 0; } if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit"); } DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit(); DistanceUnitType toUnit = convertDistanceUnit.getToUnit(); double rate = distanceConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) { if (input == null) { return 0; } if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit"); } DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit(); DistanceUnitType toUnit = convertDistanceUnit.getToUnit(); double rate = distanceConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) { if (input == null) { return 0; } if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit"); } DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit(); DistanceUnitType toUnit = convertDistanceUnit.getToUnit(); double rate = distanceConvertionTable.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 convertDistanceUnit(ConvertDistanceUnit convertDistanceUnit, Number input) { if (input == null) { return 0; } if (convertDistanceUnit == null || convertDistanceUnit.getFromUnit() == null || convertDistanceUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertDistanceUnit must be specified with fromUnit and toUnit"); } DistanceUnitType fromUnit = convertDistanceUnit.getFromUnit(); DistanceUnitType toUnit = convertDistanceUnit.getToUnit(); double rate = distanceConvertionTable.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);  }