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:ru.ksu.niimm.cll.mocassin.crawl.analyzer.relation.impl.BasicExemplifiesRelationAnalyzer.java
@Override public void addRelations(Graph<StructuralElement, Reference> graph, String paperUrl) { Iterable<StructuralElement> examples = Iterables.filter(graph.getVertices(), new TypePredicate(MocassinOntologyClasses.EXAMPLE)); MocassinOntologyClasses[] validDomains = MocassinOntologyRelations .getValidRanges(MocassinOntologyRelations.EXEMPLIFIES); int refId = -3000; // TODO: more accurate id generation is required; see // also GateReferenceSearcherImpl and other restricted relation // analyzers// ww w .jav a2 s .c om for (StructuralElement example : examples) { StructuralElement closestPredecessor = this.structuralElementSearcher.findClosestPredecessor(example, validDomains, graph); if (closestPredecessor != null) { Reference reference = new ReferenceImpl.Builder(refId--).document(new ParsedDocumentImpl(paperUrl)) .build(); reference.setPredictedRelation(MocassinOntologyRelations.EXEMPLIFIES); addEdge(graph, reference, example, closestPredecessor); } else { logger.warn( "Failed to add a relation for an example={}, because the found closest predecessor is null", example.getUri()); } } }
From source file:org.fenixedu.academic.domain.QueueJob.java
public static List<QueueJob> getUndoneJobsForClass(final Class<? extends QueueJob> type) { return Lists.<QueueJob>newArrayList(Iterables.filter(Bennu.getInstance().getQueueJobUndoneSet(), type)); }
From source file:com.vertixtech.antiquity.graph.VersionedEdgeIterable.java
@Override public Iterator<Edge> iterator() { return new Iterator<Edge>() { private final Iterator<Edge> itty = Iterables .filter(iterable, new VersionedVertexEdgePredicate<V>(graph, version)).iterator(); @Override/* www .java2s . co m*/ public void remove() { this.itty.remove(); } @Override public Edge next() { Edge edge = this.itty.next(); if (graph.isHistoricalOrInternal(edge)) { return edge; } else { return new VersionedEdge<V>(edge, graphChangedListeners, trigger, graph, version); } } @Override public boolean hasNext() { return this.itty.hasNext(); } }; }
From source file:org.jclouds.openstack.keystone.v2_0.binders.BindAuthToJsonPayload.java
protected void addCredentialsInArgsOrNull(GeneratedHttpRequest gRequest, Builder<String, Object> builder) { for (Object arg : Iterables.filter(gRequest.getInvocation().getArgs(), Predicates.notNull())) { if (arg.getClass().isAnnotationPresent(CredentialType.class)) { builder.put(arg.getClass().getAnnotation(CredentialType.class).value(), arg); }//from w ww .j av a 2 s . c om } }
From source file:ca.cutterslade.match.scheduler.Tier.java
public Iterable<Team> getTeams(Iterable<Team> allTeams) { return Iterables.filter(allTeams, teamPredicate); }
From source file:org.nickelproject.util.testUtil.ClasspathUtil.java
/** * Find classes annotated with one or more of the arguments. * * @param pAnnotations//from ww w .ja v a 2 s.co m * The annotations to look for * @return An iterable of class names */ public static Iterable<String> getAnnotatedClasses(final Class<?>... pAnnotations) { final String[] vAnnotationNames = new String[pAnnotations.length]; for (int i = 0; i < vAnnotationNames.length; i++) { vAnnotationNames[i] = pAnnotations[i].getName(); } final Iterable<String> vAllClasses = Iterables.transform(getResourcesOnClassPath("class"), new Function<String, String>() { @Override public String apply(final String pInput) { return FilenameUtils.getBaseName(pInput); } }); return Iterables.filter(vAllClasses, Predicates.and(getIsConcrete(), new HasAnnotation(vAnnotationNames))); }
From source file:org.apache.provisionr.core.activities.KillMachineSetUpProcesses.java
@Override public void execute(DelegateExecution execution) { @SuppressWarnings("unchecked") List<String> processIds = (List<String>) execution.getVariable(variableWithProcessIds); List<String> forceEnded = Lists.newArrayList(Iterables.filter(processIds, new Predicate<String>() { @Override//from www. j a v a 2s .c o m public boolean apply(String processInstanceId) { ProcessInstance instance = runtimeService.createProcessInstanceQuery() .processInstanceId(processInstanceId).singleResult(); if (instance != null && !instance.isEnded()) { runtimeService.deleteProcessInstance(processInstanceId, "Pending process needs to be killed"); return true; } return false; } })); LOG.warn("Killed pending machine setup processes: {}", forceEnded); }
From source file:org.eclipse.sirius.diagram.tools.internal.validation.description.constraints.ResolvableTypeNameConstraint.java
/** * {@inheritDoc}/* w ww. j a va 2 s.c om*/ * */ @Override public IStatus validate(final IValidationContext ctx) { final EObject eObj = ctx.getTarget(); final EMFEventType eventType = ctx.getEventType(); // In the case of batch mode. if (eventType == EMFEventType.NULL && eObj != null) { for (EAttribute feat : Iterables.filter(eObj.eClass().getEAllStructuralFeatures(), EAttribute.class)) { if (DescriptionPackage.Literals.TYPE_NAME == feat.getEType()) { Object[] result = checkIsResolvable(feat, eObj); if (result != null) { return ctx.createFailureStatus(result); } } } } return ctx.createSuccessStatus(); }
From source file:org.chaston.oakfunds.storage.mgmt.SchemaUpdater.java
Iterable<SchemaDiscrepancy> updateSchema() throws SQLException { Iterable<SchemaDiscrepancy> discrepancies = schemaValidator.validateSchema(); try (Connection connection = dataSource.getConnection()) { createMissingSchemas(connection, Iterables.filter(discrepancies, MissingSchema.class)); createMissingTables(connection, Iterables.filter(discrepancies, MissingTable.class)); handleTableDefDiscrepancies(connection, Iterables.filter(discrepancies, TableDefDiscrepancy.class)); createMissingFunctions(connection, Iterables.filter(discrepancies, MissingFunction.class)); }//from w w w .j a v a 2 s. c o m // Re-validate when done. return schemaValidator.validateSchema(); }
From source file:jp.xet.uncommons.wicket.model.FilterModel.java
@Override public List<T> getObject() { return Lists.newArrayList(Iterables.filter(delegate.getObject(), predicate)); }