@Test public void invokeListParamSupportedTypes() { FunctionTestUtil.assertResult(sumFunction.invoke(Arrays.asList(4, -1, 12.1, (long) 5, BigDecimal.TEN)), BigDecimal.valueOf(30.1)); }
public FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "the list cannot be null")); } if (list.isEmpty()) { return FEELFnResult.ofResult(null); } BigDecimal sum = BigDecimal.ZERO; for ( Object element : list ) { if ( element instanceof BigDecimal ) { sum = sum.add( (BigDecimal) element ); } else if ( element instanceof Number ) { BigDecimal value = EvalHelper.getBigDecimalOrNull( element ); if (value == null) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not suitable for the sum")); } else { sum = sum.add( value ); } } else { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not a number")); } } return FEELFnResult.ofResult( sum ); }
SumFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "the list cannot be null")); } if (list.isEmpty()) { return FEELFnResult.ofResult(null); } BigDecimal sum = BigDecimal.ZERO; for ( Object element : list ) { if ( element instanceof BigDecimal ) { sum = sum.add( (BigDecimal) element ); } else if ( element instanceof Number ) { BigDecimal value = EvalHelper.getBigDecimalOrNull( element ); if (value == null) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not suitable for the sum")); } else { sum = sum.add( value ); } } else { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not a number")); } } return FEELFnResult.ofResult( sum ); } }
SumFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "the list cannot be null")); } if (list.isEmpty()) { return FEELFnResult.ofResult(null); } BigDecimal sum = BigDecimal.ZERO; for ( Object element : list ) { if ( element instanceof BigDecimal ) { sum = sum.add( (BigDecimal) element ); } else if ( element instanceof Number ) { BigDecimal value = EvalHelper.getBigDecimalOrNull( element ); if (value == null) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not suitable for the sum")); } else { sum = sum.add( value ); } } else { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not a number")); } } return FEELFnResult.ofResult( sum ); } SumFunction(); }
SumFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "the list cannot be null")); } if (list.isEmpty()) { return FEELFnResult.ofResult(null); } BigDecimal sum = BigDecimal.ZERO; for ( Object element : list ) { if ( element instanceof BigDecimal ) { sum = sum.add( (BigDecimal) element ); } else if ( element instanceof Number ) { BigDecimal value = EvalHelper.getBigDecimalOrNull( element ); if (value == null) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not suitable for the sum")); } else { sum = sum.add( value ); } } else { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not a number")); } } return FEELFnResult.ofResult( sum ); } SumFunction(); FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list); FEELFnResult<BigDecimal> invoke(@ParameterName("list") Number single); FEELFnResult<BigDecimal> invoke(@ParameterName("n") Object[] list); }
SumFunction extends BaseFEELFunction { public FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list) { if ( list == null ) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "the list cannot be null")); } if (list.isEmpty()) { return FEELFnResult.ofResult(null); } BigDecimal sum = BigDecimal.ZERO; for ( Object element : list ) { if ( element instanceof BigDecimal ) { sum = sum.add( (BigDecimal) element ); } else if ( element instanceof Number ) { BigDecimal value = EvalHelper.getBigDecimalOrNull( element ); if (value == null) { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not suitable for the sum")); } else { sum = sum.add( value ); } } else { return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "an element in the list is not a number")); } } return FEELFnResult.ofResult( sum ); } SumFunction(); FEELFnResult<BigDecimal> invoke(@ParameterName("list") List list); FEELFnResult<BigDecimal> invoke(@ParameterName("list") Number single); FEELFnResult<BigDecimal> invoke(@ParameterName("n") Object[] list);  }