@Test public void testSubtract() { assertEquals(BigDecimal.valueOf(-8.0), NumberFieldActions.subtract(new Subtract(), Arrays.asList(new BigDecimal[] { BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4) }))); assertEquals(-8.0, NumberFieldActions.subtract(new Subtract(), Arrays.asList(1.0, 2.0, 3.0, 4.0))); assertEquals(-8L, NumberFieldActions.subtract(new Subtract(), Arrays.asList(1, 2, 3, 4))); assertEquals(0, NumberFieldActions.subtract(new Subtract(), null)); assertEquals(-8.0, NumberFieldActions.subtract(new Subtract(), Arrays.asList(null, 1.0, null, 2.0, 3.0, null, 4.0, null))); }
@AtlasActionProcessor public static Number subtract(Subtract subtract, List<Number> inputs) { if (inputs == null) { return 0; } Number difference = null; for (Object entry : inputs) { if (entry instanceof Number) { if (difference == null) { difference = (Number) entry; } else if (difference instanceof BigDecimal) { difference = ((BigDecimal) difference).subtract(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { difference = BigDecimal.valueOf(difference.doubleValue()).subtract((BigDecimal) entry); } else if (requiresDoubleResult(difference) || requiresDoubleResult(entry)) { difference = difference.doubleValue() - ((Number) entry).doubleValue(); } else { difference = difference.longValue() - ((Number) entry).longValue(); } } else { warnIgnoringValue("Subtract", entry); } } return difference; }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number subtract(Subtract subtract, List<Number> inputs) { if (inputs == null) { return 0; } Number difference = null; for (Object entry : inputs) { if (entry instanceof Number) { if (difference == null) { difference = (Number) entry; } else if (difference instanceof BigDecimal) { difference = ((BigDecimal) difference).subtract(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { difference = BigDecimal.valueOf(difference.doubleValue()).subtract((BigDecimal) entry); } else if (requiresDoubleResult(difference) || requiresDoubleResult(entry)) { difference = difference.doubleValue() - ((Number) entry).doubleValue(); } else { difference = difference.longValue() - ((Number) entry).longValue(); } } else { warnIgnoringValue("Subtract", entry); } } return difference; } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number subtract(Subtract subtract, List<Number> inputs) { if (inputs == null) { return 0; } Number difference = null; for (Object entry : inputs) { if (entry instanceof Number) { if (difference == null) { difference = (Number) entry; } else if (difference instanceof BigDecimal) { difference = ((BigDecimal) difference).subtract(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { difference = BigDecimal.valueOf(difference.doubleValue()).subtract((BigDecimal) entry); } else if (requiresDoubleResult(difference) || requiresDoubleResult(entry)) { difference = difference.doubleValue() - ((Number) entry).doubleValue(); } else { difference = difference.longValue() - ((Number) entry).longValue(); } } else { warnIgnoringValue("Subtract", entry); } } return difference; }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number subtract(Subtract subtract, List<Number> inputs) { if (inputs == null) { return 0; } Number difference = null; for (Object entry : inputs) { if (entry instanceof Number) { if (difference == null) { difference = (Number) entry; } else if (difference instanceof BigDecimal) { difference = ((BigDecimal) difference).subtract(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { difference = BigDecimal.valueOf(difference.doubleValue()).subtract((BigDecimal) entry); } else if (requiresDoubleResult(difference) || requiresDoubleResult(entry)) { difference = difference.doubleValue() - ((Number) entry).doubleValue(); } else { difference = difference.longValue() - ((Number) entry).longValue(); } } else { warnIgnoringValue("Subtract", entry); } } return difference; }  @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 subtract(Subtract subtract, List<Number> inputs) { if (inputs == null) { return 0; } Number difference = null; for (Object entry : inputs) { if (entry instanceof Number) { if (difference == null) { difference = (Number) entry; } else if (difference instanceof BigDecimal) { difference = ((BigDecimal) difference).subtract(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { difference = BigDecimal.valueOf(difference.doubleValue()).subtract((BigDecimal) entry); } else if (requiresDoubleResult(difference) || requiresDoubleResult(entry)) { difference = difference.doubleValue() - ((Number) entry).doubleValue(); } else { difference = difference.longValue() - ((Number) entry).longValue(); } } else { warnIgnoringValue("Subtract", entry); } } return difference; }  @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);  }