@Test public void testConvertVolumeUnit() { ConvertVolumeUnit action = new ConvertVolumeUnit(); action.setFromUnit(VolumeUnitType.CUBIC_METER); action.setToUnit(VolumeUnitType.CUBIC_METER); assertEquals(1.0, NumberFieldActions.convertVolumeUnit(action, 1.0)); action.setToUnit(VolumeUnitType.LITER); assertEquals(2000.0, NumberFieldActions.convertVolumeUnit(action, 2.0)); action.setToUnit(VolumeUnitType.CUBIC_FOOT); assertEquals(105.94400016446578, NumberFieldActions.convertVolumeUnit(action, 3.0)); action.setToUnit(VolumeUnitType.GALLON_US_FLUID); assertEquals(1056.68820944, NumberFieldActions.convertVolumeUnit(action, 4.0)); action.setFromUnit(VolumeUnitType.LITER); action.setToUnit(VolumeUnitType.CUBIC_METER); assertEquals(5.0, NumberFieldActions.convertVolumeUnit(action, 5000.0)); action.setToUnit(VolumeUnitType.LITER); assertEquals(6.0, NumberFieldActions.convertVolumeUnit(action, 6.0)); action.setToUnit(VolumeUnitType.CUBIC_FOOT); assertEquals(2.4720266705042016, NumberFieldActions.convertVolumeUnit(action, 70.0)); action.setToUnit(VolumeUnitType.GALLON_US_FLUID); assertEquals(2.11337641888, NumberFieldActions.convertVolumeUnit(action, 8.0)); action.setFromUnit(VolumeUnitType.CUBIC_FOOT); action.setToUnit(VolumeUnitType.CUBIC_METER); assertEquals(2.54851619328, NumberFieldActions.convertVolumeUnit(action, 90.0)); action.setToUnit(VolumeUnitType.LITER); assertEquals(28.316846591999997, NumberFieldActions.convertVolumeUnit(action, 1.0)); action.setToUnit(VolumeUnitType.CUBIC_FOOT); assertEquals(2.0, NumberFieldActions.convertVolumeUnit(action, 2.0)); action.setToUnit(VolumeUnitType.GALLON_US_FLUID); assertEquals(22.441558441715735, NumberFieldActions.convertVolumeUnit(action, 3.0)); action.setFromUnit(VolumeUnitType.GALLON_US_FLUID); action.setToUnit(VolumeUnitType.CUBIC_METER); assertEquals(1.5141647135893872, NumberFieldActions.convertVolumeUnit(action, 400.0)); action.setToUnit(VolumeUnitType.LITER); assertEquals(18.92705891986734, NumberFieldActions.convertVolumeUnit(action, 5.0)); action.setToUnit(VolumeUnitType.CUBIC_FOOT); assertEquals(8.020833333277116, NumberFieldActions.convertVolumeUnit(action, 60.0)); action.setToUnit(VolumeUnitType.GALLON_US_FLUID); assertEquals(7.0, NumberFieldActions.convertVolumeUnit(action, 7.0)); }
@AtlasActionProcessor public static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) { if (input == null) { return 0; } if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit"); } VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit(); VolumeUnitType toUnit = convertVolumeUnit.getToUnit(); double rate = volumeConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) { if (input == null) { return 0; } if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit"); } VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit(); VolumeUnitType toUnit = convertVolumeUnit.getToUnit(); double rate = volumeConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) { if (input == null) { return 0; } if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit"); } VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit(); VolumeUnitType toUnit = convertVolumeUnit.getToUnit(); double rate = volumeConvertionTable.get(fromUnit).get(toUnit); return doMultiply(input, rate); }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) { if (input == null) { return 0; } if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit"); } VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit(); VolumeUnitType toUnit = convertVolumeUnit.getToUnit(); double rate = volumeConvertionTable.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 convertVolumeUnit(ConvertVolumeUnit convertVolumeUnit, Number input) { if (input == null) { return 0; } if (convertVolumeUnit == null || convertVolumeUnit.getFromUnit() == null || convertVolumeUnit.getToUnit() == null) { throw new IllegalArgumentException("ConvertVolumeUnit must be specified with fromUnit and toUnit"); } VolumeUnitType fromUnit = convertVolumeUnit.getFromUnit(); VolumeUnitType toUnit = convertVolumeUnit.getToUnit(); double rate = volumeConvertionTable.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);  }