class DistinctValuesFunction extends BaseFEELFunction {

    public FEELFnResult<List<Object>> invoke(@ParameterName( "list" ) Object list) {
        if ( list == null ) {
            return FEELFnResult.ofError(new InvalidParametersEvent(Severity.ERROR, "list", "cannot be null"));
        }
        // spec requires us to return a new list
        final List<Object> result = new ArrayList<>();
        if ( list instanceof Collection ) {
            for (Object o : (Collection) list) {
                if ( !result.contains( o ) ) {
                    result.add(o);
                }
            }
        } else {
            result.add( list );
        }
        return FEELFnResult.ofResult( result );
    }

    public  DistinctValuesFunction();

}