@Test public void testAbsoluteValue() { assertEquals(0, NumberFieldActions.absoluteValue(new AbsoluteValue(), null)); assertEquals(BigDecimal.valueOf(1), NumberFieldActions.absoluteValue(new AbsoluteValue(), BigDecimal.valueOf(-1))); assertEquals(1.0, NumberFieldActions.absoluteValue(new AbsoluteValue(), -1.0)); assertEquals(1.0, NumberFieldActions.absoluteValue(new AbsoluteValue(), -1F)); assertEquals(1L, NumberFieldActions.absoluteValue(new AbsoluteValue(), new AtomicLong(-1L))); assertEquals(1L, NumberFieldActions.absoluteValue(new AbsoluteValue(), -1L)); assertEquals(1L, NumberFieldActions.absoluteValue(new AbsoluteValue(), new AtomicInteger(-1))); assertEquals(1L, NumberFieldActions.absoluteValue(new AbsoluteValue(), -1)); assertEquals(1L, NumberFieldActions.absoluteValue(new AbsoluteValue(), (byte) -1)); }
@AtlasActionProcessor public static Number absoluteValue(AbsoluteValue action, Number input) { if (input == null) { return 0; } if (input instanceof BigDecimal) { return ((BigDecimal) input).abs(); } if (requiresDoubleResult(input)) { return Math.abs(input.doubleValue()); } return Math.abs(input.longValue()); }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number absoluteValue(AbsoluteValue action, Number input) { if (input == null) { return 0; } if (input instanceof BigDecimal) { return ((BigDecimal) input).abs(); } if (requiresDoubleResult(input)) { return Math.abs(input.doubleValue()); } return Math.abs(input.longValue()); } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number absoluteValue(AbsoluteValue action, Number input) { if (input == null) { return 0; } if (input instanceof BigDecimal) { return ((BigDecimal) input).abs(); } if (requiresDoubleResult(input)) { return Math.abs(input.doubleValue()); } return Math.abs(input.longValue()); }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number absoluteValue(AbsoluteValue action, Number input) { if (input == null) { return 0; } if (input instanceof BigDecimal) { return ((BigDecimal) input).abs(); } if (requiresDoubleResult(input)) { return Math.abs(input.doubleValue()); } return Math.abs(input.longValue()); }  @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 absoluteValue(AbsoluteValue action, Number input) { if (input == null) { return 0; } if (input instanceof BigDecimal) { return ((BigDecimal) input).abs(); } if (requiresDoubleResult(input)) { return Math.abs(input.doubleValue()); } return Math.abs(input.longValue()); }  @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);  }