Example usage for com.google.common.collect Iterators filter

List of usage examples for com.google.common.collect Iterators filter

Introduction

In this page you can find the example usage for com.google.common.collect Iterators filter.

Prototype

@SuppressWarnings("unchecked") 
@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> UnmodifiableIterator<T> filter(Iterator<?> unfiltered, Class<T> desiredType) 

Source Link

Document

Returns all elements in unfiltered that are of the type desiredType .

Usage

From source file:org.eclipse.emf.ecoretools.design.service.DiagnosticAttachment.java

public static DiagnosticAttachment getAttachment(EObject cur) {
    Iterator<DiagnosticAttachment> it = Iterators.filter(cur.eAdapters().iterator(),
            DiagnosticAttachment.class);
    DiagnosticAttachment found = null;/*from w  w  w  .  j  a va2 s .c om*/
    if (it.hasNext()) {
        found = it.next();
    }
    return found;
}

From source file:com.proxiad.emfcustomizer.ecss.util.Iterables2.java

/**
 * Take a generic Iterable<T> and sort out all duplicates from this
 * Iterable<T>/*from w w w  . j a  v a  2 s  .c  o m*/
 * 
 * @param <T>
 * @param input
 * @return un Iterable<T> gnrique en retirant les doublons
 */
public static <T> Iterable<T> unique(final Iterable<T> input) {

    Iterable<T> unique = new AbstractIterable<T>() {
        public Iterator<T> iterator() {
            final Set<T> set = new HashSet<T>();

            return Iterators.filter(input.iterator(), new Predicate<T>() {
                public boolean apply(T input) {
                    return set.add(input);
                }
            });
        }
    };
    return unique;
}

From source file:org.peletomi.vax.impl.IterableFields.java

@Override
public Iterator<Field> iterator() {

    return Iterators.filter(new FieldIterator(instance), BeanUtils.IS_VALUE);
}

From source file:org.eclipse.emf.eson.tests.util.Find.java

public static <T extends EObject> Iterator<T> allInResourceSet(EObject context, Class<T> type) {
    Iterator<EObject> contentIterator = getResourceSetIterator(context);
    return Iterators.filter(contentIterator, type);
}

From source file:org.peletomi.vax.impl.IterableMethods.java

@Override
public Iterator<Method> iterator() {
    return Iterators.filter(new MethodIterator(instance),
            and(BeanUtils.IS_VALUE, Predicates.or(BeanUtils.IS_GETTER, BeanUtils.IS_SETTER)));
}

From source file:de.sebastianbenz.task.tagging.TagProvider.java

public Iterable<Tag> in(Resource r) {
    Iterator<Content> tasks = Iterators.filter(r.getAllContents(), Content.class);
    Iterable<Tag> result = Collections.emptyList();
    while (tasks.hasNext()) {
        result = concat(tasks.next().getTags(), result);
    }/*from   w  w  w .j ava2  s. com*/
    return result;
}

From source file:org.apache.jackrabbit.oak.security.user.AuthorizableIterator.java

static AuthorizableIterator create(Iterator<String> authorizableOakPaths, UserManagerImpl userManager,
        AuthorizableType authorizableType) {
    Iterator it = Iterators.transform(authorizableOakPaths,
            new PathToAuthorizable(userManager, authorizableType));
    long size = getSize(authorizableOakPaths);
    return new AuthorizableIterator(Iterators.filter(it, Predicates.notNull()), size);
}

From source file:org.graylog2.plugin.MessageCollection.java

@Override
public Iterator<Message> iterator() {
    return Iterators.filter(messages.iterator(), e -> !e.getFilterOut());
}

From source file:com.googlecode.efactory.util.Find.java

public static <T extends EObject> Iterator<T> allInResourceSet(EObject context, Class<T> type) {

    Iterator<EObject> contentIterator = getResourceSetIterator(context);
    return Iterators.filter(contentIterator, type);
}

From source file:edu.umd.cs.psl.evaluation.statistics.filter.InSetFilter.java

@Override
public Iterator<Atom> filter(Iterator<Atom> input) {
    return Iterators.filter(input, new Predicate<Atom>() {
        @Override//from  w  ww. j a  va2 s.c om
        public boolean apply(Atom atom) {
            return atoms.contains(atom);
        }

    });
}