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:org.eclipse.sirius.business.internal.contribution.ContributionFinder.java
/** * Returns a contribution provider which looks for all the * {@link Contribution} elements contained inside the input model (including * the input model itself if it is a contribution. * /*from w w w.j av a2 s . c om*/ * @return a function which finds all the Contribution elements in the input * model. */ public static Function<Iterable<EObject>, Iterable<Contribution>> intrinsic() { return new Function<Iterable<EObject>, Iterable<Contribution>>() { public Iterable<Contribution> apply(Iterable<EObject> from) { List<Contribution> result = Lists.newArrayList(); for (EObject root : from) { Iterables.addAll(result, Iterables.filter( AllContents.of(root, ContributionPackage.eINSTANCE.getContribution(), true), Contribution.class)); } return result; } }; }
From source file:org.eclipse.xtext.resource.containers.FilterUriContainer.java
@Override public Iterable<IResourceDescription> getResourceDescriptions() { return Iterables.filter(delegate.getResourceDescriptions(), new Predicate<IResourceDescription>() { @Override//from w w w . j av a 2 s . c om public boolean apply(IResourceDescription input) { return !input.getURI().equals(filterMe); } }); }
From source file:org.linqs.psl.application.groundrulestore.MemoryGroundRuleStore.java
@Override public Iterable<UnweightedGroundRule> getConstraintRules() { return Iterables.filter(groundRules.values(), UnweightedGroundRule.class); }
From source file:org.polarsys.reqcycle.traceability.types.configuration.preferences.providers.PreferenceDialogTypesContentProvider.java
@Override public Object[] getChildren(Object object) { if (object instanceof TypeConfigContainer) { return Lists.newArrayList( Iterables.filter(Arrays.asList(super.getChildren(object)), new Predicate<Object>() { public boolean apply(Object o) { boolean result = (!(o instanceof CustomType)); if (result) { if (o instanceof Type) { Type type = (Type) o; return type.getIType() != null && type.getIType().getSuperType() == null; }/*ww w.ja va 2s .c o m*/ } return result; } })).toArray(); } else if (object instanceof Type) { List<Object> list = new LinkedList<Object>(); for (Type type : container.getTypes()) { if (type instanceof CustomType) { CustomType cust = (CustomType) type; if (cust.getSuperType() == object) { list.add(cust); } } else { if (type.getIType() != null) { IType superType = type.getIType().getSuperType(); if (superType != null && superType.getId().equals(((Type) object).getTypeId())) { list.add(type); } } } } return list.toArray(); } return super.getChildren(object); }
From source file:ru.ksu.niimm.cll.mocassin.crawl.analyzer.relation.impl.BasicHasConsequenceRelationAnalyzer.java
/** * {@inheritDoc}/* w w w .ja va 2 s. com*/ */ @Override public void addRelations(Graph<StructuralElement, Reference> graph, String paperUrl) { Iterable<StructuralElement> corollaries = Iterables.filter(graph.getVertices(), new TypePredicate(MocassinOntologyClasses.COROLLARY)); MocassinOntologyClasses[] validDomains = MocassinOntologyRelations .getValidDomains(MocassinOntologyRelations.HAS_CONSEQUENCE); int refId = -1000; // TODO: more accurate id generation is required; see // also GateReferenceSearcherImpl and other restricted relation // analyzers for (StructuralElement corollary : corollaries) { StructuralElement closestPredecessor = this.structuralElementSearcher.findClosestPredecessor(corollary, validDomains, graph); if (closestPredecessor != null) { Reference reference = new ReferenceImpl.Builder(refId--).document(new ParsedDocumentImpl(paperUrl)) .build(); reference.setPredictedRelation(MocassinOntologyRelations.HAS_CONSEQUENCE); addEdge(graph, reference, closestPredecessor, corollary); } else { logger.warn( "Failed to add a relation for a corollary={}, because the found closest predecessor is null", corollary.getUri()); } } }
From source file:org.eclipse.wb.internal.core.model.util.ObjectsTreeContentProvider.java
public Object[] getChildren(Object parentElement) { List<ObjectInfo> children = ((ObjectInfo) parentElement).getChildren(); Iterable<ObjectInfo> filtered = Iterables.filter(children, m_predicate); return Iterables.toArray(filtered, ObjectInfo.class); }
From source file:org.dyndns.jkiddo.dmp.chunks.media.Listing.java
public Iterable<ListingItem> getListingItems(Predicate<ListingItem> predicate) { return Iterables.filter(getListingItems(), predicate); }
From source file:com.axmor.eclipse.typescript.core.index.TypeScriptIndexManager.java
public Iterable<IndexInfo> searchByName(final String name) { return Iterables.transform(Iterables.filter(job.getIndexer().idxTypes, new Predicate<Fun.Tuple4<String, String, String, IndexInfo>>() { @Override/*from ww w .java2 s .c om*/ public boolean apply(Tuple4<String, String, String, IndexInfo> input) { if (name.startsWith("*")) { return name.length() < 2 || input.b.toLowerCase().contains(name.substring(1).toLowerCase()); } else { return input.b.toLowerCase().startsWith(name.toLowerCase()); } } }), new Function<Fun.Tuple4<String, String, String, IndexInfo>, IndexInfo>() { @Override public IndexInfo apply(Tuple4<String, String, String, IndexInfo> input) { return input.d; } }); }
From source file:gg.uhc.uhc.modules.WorldMatcher.java
public WorldMatcher(ConfigurationSection section, List<String> worldsDefault, boolean isWhitelistDefault) { if (!section.contains(WORLDS_KEY)) { section.set(WORLDS_KEY, worldsDefault); }/*from w w w . j a v a 2 s. co m*/ if (!section.contains(IS_WHITELIST_KEY)) { section.set(IS_WHITELIST_KEY, isWhitelistDefault); } worlds = ImmutableSet.copyOf(Iterables.filter( Iterables.transform(section.getStringList(WORLDS_KEY), TO_LOWER_CASE), Predicates.notNull())); isWhitelist = section.getBoolean(IS_WHITELIST_KEY); }
From source file:playground.michalm.util.gis.PolygonBasedFilter.java
public static Iterable<? extends Link> filterLinksOutsidePolygon(Iterable<? extends Link> links, Geometry polygonGeometry, boolean includeBorderLinks) { return Iterables.filter(links, Predicates.not(createLinkInsidePolygonPredicate(polygonGeometry, !includeBorderLinks)));// includeBorderLinks must be negated }