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

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

Introduction

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

Prototype



@CheckReturnValue
public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate) 

Source Link

Document

Returns the elements of unfiltered that satisfy a predicate.

Usage

From source file:com.google.security.zynamics.binnavi.debug.models.trace.AbstractTraceProvider.java

/**
 * Determines whether there exists a trace with the given name.
 *
 * @param name The name of the trace./*from w  ww .j a  v a2  s. com*/
 * @param traces List of traces to search through.
 * @return Returns if a trace with the given name exists in the trace.
 */
private static boolean hasTrace(final String name, final List<TraceList> traces) {
    return !Collections2.filter(traces, new Predicate<TraceList>() {
        @Override
        public boolean apply(final TraceList trace) {
            return trace.getName().equals(name);
        }
    }).isEmpty();
}

From source file:org.activityinfo.legacy.shared.model.AdminLevelPredicates.java

public static List<AdminLevelDTO> breadthFirstSort(List<AdminLevelDTO> allLevels) {
    List<AdminLevelDTO> sorted = Lists.newArrayList();
    Predicate<AdminLevelDTO> predicate = rootLevels();
    Collection<AdminLevelDTO> next;
    while (!(next = Collections2.filter(allLevels, predicate)).isEmpty()) {
        sorted.addAll(next);/* w w  w  . j a  va2  s  .  co m*/
        predicate = childrenOf(next);
    }
    return sorted;
}

From source file:org.batoo.jpa.parser.MappingException.java

private static String getLocation(AbstractLocator[] locators) {
    if (locators == null) {
        return "";
    }/*from w ww.j  av a 2  s  . c  o  m*/

    final Collection<AbstractLocator> filteredLocators = Collections2.filter(Arrays.asList(locators),
            Predicates.not(Predicates.isNull()));
    if (filteredLocators.size() == 0) {
        return "";
    }

    return " Defined at:" + (filteredLocators.size() > 1 ? "\n\t" : " ")
            + Joiner.on("\n\t").skipNulls().join(filteredLocators);
}

From source file:com.madvay.tools.android.perf.common.TraceTransformers.java

public static TT prune(final Predicate<StackTraceElement> spec) {
    return new TT() {
        @Override/*from  w  ww .  j a  v  a  2s.  com*/
        public List<StackTraceElement> apply(List<StackTraceElement> input) {
            return Lists.newArrayList(Collections2.filter(input, Predicates.not(spec)));
        }
    };
}

From source file:io.crate.planner.projection.Projections.java

public static Collection<? extends Projection> nodeProjections(Collection<? extends Projection> projections) {
    return Collections2.filter(projections, Projection.IS_NODE_PROJECTION);
}

From source file:pl.coffeepower.blog.examples.NumberUtils.java

public static Collection<? extends Number> getOddNumbers(Collection<? extends Number> numbers) {
    return Collections2.filter(numbers, number -> isOddNumber(number));
}

From source file:io.crate.execution.dsl.projection.Projections.java

public static Collection<? extends Projection> nodeProjections(Collection<? extends Projection> projections) {
    return Collections2.filter(projections, Projection.IS_NODE_PROJECTION::test);
}

From source file:de.flapdoodle.embed.redis.Enums.java

public static <T extends Enum<T>> Collection<T> filter(Collection<T> source, Predicate<? super T> predicate) {
    return Collections2.filter(source, predicate);
}

From source file:org.killbill.billing.plugin.adyen.client.payment.service.PayPalCountryCodes.java

public static boolean isNotPayPalIsoCode(final String countryIsoCode) {
    return Collections2.filter(paypalIsoCountryCodes, new Predicate<String>() {
        @Override/*from  w  w w. ja v a 2 s .c  om*/
        public boolean apply(final String country) {
            return country != null && country.equalsIgnoreCase(countryIsoCode);
        }
    }).isEmpty();
}

From source file:com.google.security.zynamics.binnavi.disassembly.views.CViewFilter.java

/**
 * Returns the number of views which match the given type.
 * /*from   ww w  .  j  a va 2s . c om*/
 * @param views The list of available views.
 * @param type The type of view to match.
 * @return The number of views matching the given type.
 */
private static Iterable<INaviView> getViewsByType(final List<INaviView> views, final GraphType type) {
    return Collections2.filter(views, new Predicate<INaviView>() {
        @Override
        public boolean apply(final INaviView view) {
            return view.getGraphType() == type;
        }
    });
}