@Test(expected = IllegalArgumentException.class) public void testConvertDistanceUnitIllegalArgumentException() { assertEquals(0, NumberFieldActions.convertDistanceUnit(new ConvertDistanceUnit(), null).intValue()); NumberFieldActions.convertDistanceUnit(new ConvertDistanceUnit(), 5); }
@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);  }