public static Iterable<Item> getFavorites(@Nonnull User user) {
        FavoriteUserProperty fup = user.getProperty(FavoriteUserProperty.class);
        if (fup == null) {
            return ImmutableList.of();
        }
        Set<String> favorites = fup.getAllFavorites();
        if (favorites.isEmpty()) {
            return ImmutableList.of();
        }
        final Iterator<String> iterator = favorites.iterator();
        final Jenkins jenkins = Jenkins.getInstance();
        if (jenkins == null) {
            throw new IllegalStateException("Jenkins not started");
        }
        return new Iterable<Item>() {
            @Override
            public Iterator<Item> iterator() {
                return Iterators.filter(new Iterator<Item>() {
                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public Item next() {
                        return jenkins.getItemByFullName(iterator.next());
                    }
                    
                    /* Fix build. */
                    @Override
                    public void remove() {
                        throw new UnsupportedOperationException();
                    }
                }, Predicates.<Item>notNull());
            }
        };
    }
public static Iterable < Item > getFavorites ( @ Nonnull User user ) { FavoriteUserProperty fup = user . getProperty ( FavoriteUserProperty . class ) ; if ( fup == null ) { return ImmutableList . of ( ) ; } Set < String > favorites = fup . getAllFavorites ( ) ; if ( favorites . isEmpty ( ) ) { return ImmutableList . of ( ) ; } final Iterator < String > iterator = favorites . iterator ( ) ; final Jenkins jenkins = Jenkins . getInstance ( ) ; if ( jenkins == null ) { throw new IllegalStateException ( "Jenkins not started" ) ; } return new Iterable < Item > ( ) { @ Override public Iterator < Item > iterator ( ) { return Iterators . filter ( new Iterator < Item > ( ) { @ Override public boolean hasNext ( ) { return iterator . hasNext ( ) ; } @ Override public Item next ( ) { return jenkins . getItemByFullName ( iterator . next ( ) ) ; } @ Override public void remove ( ) { throw new UnsupportedOperationException ( ) ; } } , Predicates . < Item > notNull ( ) ) ; } } ; }
Get all items that the provided user has favorited
@param user to lookup favorites for
@return favorite items