Dan Haywood created ISIS-1331:
---------------------------------

             Summary: If return a google guava collection from an autoComplete 
or choices, then throws exception due to unsupported classes.
                 Key: ISIS-1331
                 URL: https://issues.apache.org/jira/browse/ISIS-1331
             Project: Isis
          Issue Type: Improvement
          Components: Core
    Affects Versions: 1.11.1
            Reporter: Dan Haywood
            Assignee: Dan Haywood
            Priority: Minor
             Fix For: 1.13.0


For example, this seemingly innocuous code:

{code}
    public List<SimpleObject> autoComplete(@MinLength(2) String search) {
        return
                    FluentIterable.from(listAll())
                    .filter(new Predicate<SimpleObject>() {
                        @Override public boolean apply(@Nullable final 
SimpleObject object) {
                            return object.getName().contains(search);
                        }
                    })
                    .toList();
    }
{code}

will fail.  to make it work, the developer needs to copy to an ArrayList, eg:

{code}
    public List<SimpleObject> autoComplete(@MinLength(2) String search) {
        return
                Lists.newArrayList(
                    FluentIterable.from(listAll())
                    .filter(new Predicate<SimpleObject>() {
                        @Override public boolean apply(@Nullable final 
SimpleObject object) {
                            return object.getName().contains(search);
                        }
                    })
                    .toList()
                );
    }
{code}

One possible solution is for the framework to do this automatically, for List, 
Set, Collection.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to