@Test public void testMultiply() { assertNotNull(new NumberFieldActions()); assertEquals(0, NumberFieldActions.multiply(new Multiply(), null)); assertEquals(new BigDecimal("24.0000"), NumberFieldActions.multiply(new Multiply(), Arrays.asList(new BigDecimal[] { BigDecimal.valueOf(1), BigDecimal.valueOf(2), BigDecimal.valueOf(3), BigDecimal.valueOf(4) }))); assertEquals(24.0, NumberFieldActions.multiply(new Multiply(), Arrays.asList(1.0, 2.0, 3.0, 4.0 ))); assertEquals(24.0, NumberFieldActions.multiply(new Multiply(), Arrays.asList(1.0f, 2.0f, 3.0f, 4.0f))); assertEquals(24L, NumberFieldActions.multiply(new Multiply(), Arrays.asList(1L, 2L, 3L, 4L))); assertEquals(24L, NumberFieldActions.multiply(new Multiply(), Arrays.asList(1, 2, 3, 4))); assertEquals(24L, NumberFieldActions.multiply(new Multiply(), Arrays.asList(null, 1, 2, null, 3, 4, null))); }
@AtlasActionProcessor public static Number multiply(Multiply multiply, List<Number> inputs) { if (inputs == null) { return 0; } Number product = 1L; for (Object entry : inputs) { if (entry instanceof Number) { if (product instanceof BigDecimal) { product = ((BigDecimal) product).multiply(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { product = BigDecimal.valueOf(product.doubleValue()).multiply((BigDecimal) entry); } else if (requiresDoubleResult(product) || requiresDoubleResult(entry)) { product = product.doubleValue() * ((Number) entry).doubleValue(); } else { product = product.longValue() * ((Number) entry).longValue(); } } else { warnIgnoringValue("Multiply", entry); } } return product; }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number multiply(Multiply multiply, List<Number> inputs) { if (inputs == null) { return 0; } Number product = 1L; for (Object entry : inputs) { if (entry instanceof Number) { if (product instanceof BigDecimal) { product = ((BigDecimal) product).multiply(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { product = BigDecimal.valueOf(product.doubleValue()).multiply((BigDecimal) entry); } else if (requiresDoubleResult(product) || requiresDoubleResult(entry)) { product = product.doubleValue() * ((Number) entry).doubleValue(); } else { product = product.longValue() * ((Number) entry).longValue(); } } else { warnIgnoringValue("Multiply", entry); } } return product; } }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number multiply(Multiply multiply, List<Number> inputs) { if (inputs == null) { return 0; } Number product = 1L; for (Object entry : inputs) { if (entry instanceof Number) { if (product instanceof BigDecimal) { product = ((BigDecimal) product).multiply(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { product = BigDecimal.valueOf(product.doubleValue()).multiply((BigDecimal) entry); } else if (requiresDoubleResult(product) || requiresDoubleResult(entry)) { product = product.doubleValue() * ((Number) entry).doubleValue(); } else { product = product.longValue() * ((Number) entry).longValue(); } } else { warnIgnoringValue("Multiply", entry); } } return product; }  }
NumberFieldActions implements AtlasFieldAction { @AtlasActionProcessor public static Number multiply(Multiply multiply, List<Number> inputs) { if (inputs == null) { return 0; } Number product = 1L; for (Object entry : inputs) { if (entry instanceof Number) { if (product instanceof BigDecimal) { product = ((BigDecimal) product).multiply(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { product = BigDecimal.valueOf(product.doubleValue()).multiply((BigDecimal) entry); } else if (requiresDoubleResult(product) || requiresDoubleResult(entry)) { product = product.doubleValue() * ((Number) entry).doubleValue(); } else { product = product.longValue() * ((Number) entry).longValue(); } } else { warnIgnoringValue("Multiply", entry); } } return product; }  @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 multiply(Multiply multiply, List<Number> inputs) { if (inputs == null) { return 0; } Number product = 1L; for (Object entry : inputs) { if (entry instanceof Number) { if (product instanceof BigDecimal) { product = ((BigDecimal) product).multiply(BigDecimal.valueOf(((Number) entry).doubleValue())); } else if (entry instanceof BigDecimal) { product = BigDecimal.valueOf(product.doubleValue()).multiply((BigDecimal) entry); } else if (requiresDoubleResult(product) || requiresDoubleResult(entry)) { product = product.doubleValue() * ((Number) entry).doubleValue(); } else { product = product.longValue() * ((Number) entry).longValue(); } } else { warnIgnoringValue("Multiply", entry); } } return product; }  @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);  }