List of usage examples for com.google.common.collect Iterables filter
@GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType)
From source file:com.isotrol.impe3.api.component.sitemap.Sitemap.java
private static <T> ImmutableList<T> create(Iterable<T> entries) { if (entries == null) { return ImmutableList.of(); } else {//www. j a v a 2 s . c om return ImmutableList.copyOf(Iterables.filter(entries, Predicates.notNull())); } }
From source file:org.trancecode.xml.saxon.SaxonAxis.java
public static Iterable<XdmNode> attributes(final XdmNode node) { return Iterables.filter(childNodes(node), SaxonPredicates.isAttribute()); }
From source file:org.robotframework.red.viewers.Selections.java
public static <T> List<T> getAdaptableElements(final IStructuredSelection selection, final Class<T> elementsClass) { final List<?> selectionAsList = selection.toList(); return newArrayList(Iterables.filter( transform(selectionAsList, toObjectOfClassUsingAdapters(elementsClass)), Predicates.notNull())); }
From source file:uk.co.blackpepper.common.model.Identifiables.java
public static <T extends Identifiable<?>> Iterable<T> getTransients(Iterable<T> identifiables) { return Iterables.filter(identifiables, Predicates.not(arePersistent())); }
From source file:uk.ac.stfc.isis.ibex.configserver.internal.DisplayUtils.java
public static <T extends Group> Collection<T> removeOtherGroup(Collection<T> groups) { return Lists.newArrayList(Iterables.filter(groups, new Predicate<T>() { @Override//from w w w .j a v a2s .c o m public boolean apply(T group) { return !group.getName().equals(OTHER); } })); }
From source file:ratpack.handling.internal.DescribingHandlers.java
public static void describeTo(Handler handler, StringBuilder stringBuilder) { Class<? extends Handler> clazz = handler.getClass(); if (clazz.isAnonymousClass()) { ClassPool pool = ClassPool.getDefault(); CtClass ctClass;/*from w ww. j a v a 2s . c o m*/ try { ctClass = pool.get(clazz.getName()); CtBehavior[] behaviors = ctClass.getDeclaredBehaviors(); Iterable<CtBehavior> withLineNumberIterable = Iterables.filter(Arrays.asList(behaviors), input -> input.getMethodInfo().getLineNumber(0) > 0); LinkedList<CtBehavior> withLineNumber = Lists.newLinkedList(withLineNumberIterable); Collections.sort(withLineNumber, (o1, o2) -> Integer.valueOf(o1.getMethodInfo().getLineNumber(0)) .compareTo(o2.getMethodInfo().getLineNumber(0))); if (!withLineNumber.isEmpty()) { CtBehavior method = withLineNumber.get(0); int lineNumber = method.getMethodInfo().getLineNumber(0); ClassFile classFile = ctClass.getClassFile(); String sourceFile = classFile.getSourceFile(); if (lineNumber != -1 && sourceFile != null) { stringBuilder.append("anonymous class ").append(clazz.getName()) .append(" at approximately line ").append(lineNumber).append(" of ") .append(sourceFile); return; } } } catch (NotFoundException ignore) { // fall through } } stringBuilder.append(clazz.getName()); }
From source file:org.eclipse.incquery.patternlanguage.emf.helper.EMFPatternLanguageHelper.java
/** * Returns an iterable of package imports in a selected pattern model * /* w ww .j a va 2 s . co m*/ * @param model * @return */ public static Iterable<PackageImport> getPackageImportsIterable(PatternModel model) { return Iterables.filter(model.getImportPackages(), PackageImport.class); }
From source file:org.apache.whirr.service.puppet.predicates.PuppetPredicates.java
public static Predicate<String> isFirstPuppetRoleIn(final Iterable<String> roles) { return new Predicate<String>() { @Override/*from ww w. j ava 2 s. c o m*/ public boolean apply(String arg0) { return Iterables .get(Iterables.filter(roles, Predicates.containsPattern("^" + PUPPET_ROLE_PREFIX + arg0)), 0) .equals(PUPPET_ROLE_PREFIX + arg0); } @Override public String toString() { return "isFirstPuppetRoleIn(" + roles + ")"; } }; }
From source file:com.francetelecom.clara.cloud.coremodel.MiddlewareProfile.java
/** * Filter a collection of MiddlewareProfile to collect only visible ones * (based on user parameter)// www .j av a2 s .c o m * * @param user * @param profiles * @return */ public static Set<MiddlewareProfile> filter(final PaasUser user, Collection<MiddlewareProfile> profiles) { return Sets.newHashSet(Iterables.filter(profiles, new Predicate<MiddlewareProfile>() { @Override public boolean apply(MiddlewareProfile profile) { return profile.getStatus().isAllowedFor(user.getPaasUserRole()); } })); }
From source file:org.isisaddons.app.kitchensink.dom.dependent.NflRegion.java
public static List<NflRegion> thoseFor(final NflLeague league) { return Lists.newArrayList(Iterables.filter(Arrays.asList(values()), new Predicate<NflRegion>() { @Override//from w w w . j a v a 2s. c o m public boolean apply(NflRegion input) { return input.getLeague() == league; } })); }