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.facebook.buck.artifact_cache.MultiArtifactCache.java
public MultiArtifactCache(ImmutableList<ArtifactCache> artifactCaches) { this.artifactCaches = artifactCaches; this.writableArtifactCaches = ImmutableList .copyOf(Iterables.filter(artifactCaches, ArtifactCache::isStoreSupported)); this.isStoreSupported = this.writableArtifactCaches.size() > 0; }
From source file:eu.interedition.collatex.neo4j.Neo4jVariantGraphTransposition.java
public Neo4jVariantGraphTransposition(Neo4jVariantGraph graph, Set<VariantGraph.Vertex> vertices) { this(graph, graph.database.createNode()); for (Neo4jVariantGraphVertex vertex : Iterables.filter(vertices, Neo4jVariantGraphVertex.class)) { this.node.createRelationshipTo(vertex.node, Neo4jGraphRelationships.TRANSPOSITION); }//from w w w. j a v a 2 s .com }
From source file:org.apache.gobblin.data.management.retention.test.ContainsStringRetentionPolicy.java
@Override public Collection<StringDatasetVersion> listDeletableVersions(List<StringDatasetVersion> allVersions) { return Lists.newArrayList(Iterables.filter(allVersions, new Predicate<StringDatasetVersion>() { @Override//w w w . j a va 2 s. co m public boolean apply(StringDatasetVersion input) { return input.getVersion().contains(getSearchToken()); } })); }
From source file:org.fenixedu.academic.domain.QueueJob.java
public static List<QueueJob> getAllJobsForClassOrSubClass(final Class<? extends QueueJob> type, int maxSize, Comparator<QueueJob> comparator) { List<QueueJob> jobs = Lists .<QueueJob>newArrayList(Iterables.filter(Bennu.getInstance().getQueueJobSet(), type)); Collections.sort(jobs, comparator); return jobs.size() > maxSize ? jobs.subList(0, maxSize) : jobs; }
From source file:org.eclipse.sirius.table.ui.tools.internal.editor.action.EditorCreateTargetColumnMenuAction.java
/** * {@inheritDoc}//from w ww . j ava 2 s. co m */ @Override protected List<CreateTargetColumnAction> filter(List<AbstractToolAction> createActionsForTable) { return Lists.newArrayList(Iterables.filter(createActionsForTable, CreateTargetColumnAction.class)); }
From source file:clocker.docker.location.strategy.BasicDockerPlacementStrategy.java
@Override public List<DockerHostLocation> filterLocations(List<DockerHostLocation> locations, Entity context) { if (locations == null || locations.isEmpty()) { return ImmutableList.of(); }// w ww . j a va2 s.com entity = context; List<DockerHostLocation> available = MutableList.copyOf(locations); Collections.sort(available, this); return ImmutableList.copyOf(Iterables.filter(available, this)); }
From source file:org.jpmml.evaluator.functions.AggregateFunction.java
@Override public FieldValue evaluate(List<FieldValue> arguments) { StorelessUnivariateStatistic statistic = createStatistic(); DataType dataType = null;//from ww w . j av a 2s. com // "Missing values in the input to an aggregate function are simply ignored" Iterable<FieldValue> values = Iterables.filter(arguments, Predicates.notNull()); for (FieldValue value : values) { statistic.increment((value.asNumber()).doubleValue()); if (dataType != null) { dataType = TypeUtil.getResultDataType(dataType, value.getDataType()); } else { dataType = value.getDataType(); } } if (statistic.getN() == 0) { throw new InvalidResultException(null); } Object result = cast(getResultType(dataType), statistic.getResult()); return FieldValueUtil.create(result); }
From source file:org.eclipse.sirius.ui.tools.internal.actions.session.OpenSessionAction.java
/** * Looks for selected {@link IFile}s to open sessions. * /*from www . j a v a 2 s .com*/ * {@inheritDoc} */ @Override protected boolean updateSelection(IStructuredSelection selection) { if (selection != null) { this.selectedFiles = Sets.newLinkedHashSet(Iterables.filter(selection.toList(), IFile.class)); } return super.updateSelection(selection) && selectedFiles != null && !selectedFiles.isEmpty(); }
From source file:org.eclipse.xtext.util.formallang.ProductionStringFactory.java
@Override public String createForSequentialChildren(boolean many, boolean optional, Iterable<String> children) { children = Iterables.filter(children, Predicates.notNull()); if (many || optional) return "(" + Joiner.on(" ").join(children) + ")" + card(many, optional); return Joiner.on(" ").join(children) + card(many, optional); }
From source file:jp.xet.uncommons.wicket.model.SingleSelectModel.java
@Override public T getObject() { return Iterables.getFirst(Iterables.filter(delegate.getObject(), predicate), null); }