class UnionFunction extends BaseFEELFunction {

    public FEELFnResult<List<Object>> invoke(@ParameterName("list") Object[] lists) {
        if ( lists == null ) {
            return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "lists", "cannot be null"));
        }

        final Set<Object> resultSet = new LinkedHashSet<>();
        for ( final Object list : lists ) {
            if ( list instanceof Collection ) {
                resultSet.addAll((Collection) list);
            } else {
                resultSet.add(list);
            }
        }

        // spec requires us to return a new list
        return FEELFnResult.ofResult( new ArrayList<>(resultSet) );
    }

    public  UnionFunction();

}