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.diagram.ui.tools.internal.actions.repair.AbstractAbstractDNodeDiagramElementState.java
/** * {@inheritDoc}/*from w w w .j av a 2 s. c o m*/ * * @see org.eclipse.sirius.diagram.tools.internal.actions.repair.AbstractDiagramElementState#storeElementState(EObject, * DiagramElementMapping, org.eclipse.sirius.diagram.DDiagramElement) */ @Override public void storeElementState(EObject target, DiagramElementMapping mapping, D element) { super.storeElementState(target, mapping, element); Iterable<ArrangeConstraint> existingArrangeConstraints = Iterables.filter(element.getArrangeConstraints(), ArrangeConstraint.class); if (!Iterables.isEmpty(existingArrangeConstraints)) { Iterables.addAll(arrangeConstraints, existingArrangeConstraints); } }
From source file:edu.umn.msi.tropix.persistence.service.impl.SampleServiceImpl.java
public ProteomicsRun[] getProteomicsRuns(final String userId, final String tissueSampleId) { final TissueSample sample = getTropixObjectDao().loadTropixObject(tissueSampleId, TissueSample.class); Iterable<ProteomicsRun> runs = sample.getProteomicsRuns(); if (runs == null) { runs = Lists.newArrayList();//from www .j a v a2 s . co m } return Iterables.toArray( Iterables.filter(runs, Predicates.getValidAndCanReadPredicate(getSecurityProvider(), userId)), ProteomicsRun.class); }
From source file:com.github.malibu_lib.internal.PointcutManager.java
@SuppressWarnings("unchecked") private <A> Iterable<A> advices(Class<A> pointcut, Iterable<Advice> listeners, HashMap<Class<?>, Iterable<Class<?>>> cache) { Iterable<A> result = (Iterable<A>) cache.get(pointcut); if (result == null) { result = Iterables.filter(listeners, pointcut); cache.put(pointcut, (Iterable<Class<?>>) result); }//from w ww . ja va 2s. c o m return result; }
From source file:org.eclipse.incquery.patternlanguage.emf.scoping.EMFPatternLanguageImportedNamespaceAwareLocalScopeProvider.java
@Override protected List<ImportNormalizer> internalGetImportedNamespaceResolvers(EObject context, boolean ignoreCase) { List<ImportNormalizer> result = new ArrayList<ImportNormalizer>( super.internalGetImportedNamespaceResolvers(context, ignoreCase)); if (context instanceof PatternCall) { PatternModel model = EcoreUtil2.getContainerOfType(context, PatternModel.class); if (model != null) { if (model.getPackageName() != null && !model.getPackageName().isEmpty()) { result.add(createImportedNamespaceResolver(model.getPackageName() + ".*", ignoreCase)); }//from w w w.ja v a2 s .com for (JavaImport importDecl : Iterables.filter(model.getImportPackages(), JavaImport.class)) { if (importDecl.getImportedNamespace() != null) { result.add(createImportedNamespaceResolver(importDecl.getImportedNamespace() + ".*", ignoreCase)); } } } } return result; }
From source file:com.eucalyptus.reporting.export.Export.java
public static ReportingExport export(final Date startDate, final Date endDate, final boolean includeDependencies) { final ReportingExport export = new ReportingExport(); final Conjunction criterion = Restrictions.conjunction(); if (startDate != null) { criterion.add(Restrictions.ge(CREATION_TIMESTAMP, startDate)); }// w ww . j av a 2 s. c o m if (endDate != null) { criterion.add(Restrictions.lt(CREATION_TIMESTAMP, endDate)); } final List<ReportingEventSupport> actions = Lists.newArrayList(); export.addUsage( Iterables.filter( Iterables.transform( iterableExporter(criterion, getUsageClasses(), Collections.<ReportingEventSupport>emptyList(), includeDependencies), ExportUtils.toExportUsage(includeDependencies ? actions : null)), Predicates.notNull())); export.addActions( Iterables .transform( Iterables.concat(actions, iterableExporter(criterion, getEventClasses(), actions, includeDependencies)), Functions.compose(userAccountDecorator(), ExportUtils.toExportAction()))); return export; }
From source file:com.google.devtools.build.lib.rules.cpp.UmbrellaHeaderAction.java
public UmbrellaHeaderAction(ActionOwner owner, Artifact umbrellaHeader, Iterable<Artifact> publicHeaders, Iterable<PathFragment> additionalExportedHeaders) { super(owner, ImmutableList.copyOf(Iterables.filter(publicHeaders, Artifact.IS_TREE_ARTIFACT)), umbrellaHeader, /*makeExecutable=*/false); this.umbrellaHeader = umbrellaHeader; this.publicHeaders = ImmutableList.copyOf(publicHeaders); this.additionalExportedHeaders = ImmutableList.copyOf(additionalExportedHeaders); }
From source file:org.summer.ss.lib.macro.file.Path.java
/** * Constructs a new Path object from a given string. * /*w ww. j a va 2s.c o m*/ * the used file separator is '/' and a leading one indicates an absolute path. * * @param pathAsString */ public Path(String pathAsString) { if (pathAsString == null) throw new NullPointerException(); if (pathAsString.trim().length() == 0) throw new IllegalArgumentException("empty path"); pathAsString = pathAsString.replace('\\', SEGMENT_SEPARATOR); //replace windows separators Iterable<String> iterable = splitter.split(pathAsString); // if the first element is empty it has a leading separator; this.absolute = iterable.iterator().next().length() == 0; Iterable<String> withoutEmptySegements = Iterables.filter(iterable, new Predicate<String>() { public boolean apply(String input) { return input != null && input.trim().length() > 0; } }); segments = ImmutableList.copyOf(normalize(withoutEmptySegements)); }
From source file:org.impressivecode.depress.support.activitymatcher.ActivityMarkerCellFactory.java
private Iterable<ITSDataType> findIssuesFromGivenInterval(final long commitTimeInMillis) { final long min = commitTimeInMillis - this.cfg.getIntervalInMillis(); final long max = commitTimeInMillis + this.cfg.getIntervalInMillis(); return Iterables.filter(this.cfg.getIssues(), new Predicate<ITSDataType>() { @Override/*from w w w . j a v a 2 s . c om*/ public boolean apply(final ITSDataType issue) { return min < issue.getResolved().getTime() && issue.getResolved().getTime() < max; } }); }
From source file:org.cloudifysource.cosmo.kvstore.KVStore.java
@Override public Iterable<URI> listKeysStartsWith(final URI keyPrefix) { return Iterables.filter(store.keySet(), new Predicate<URI>() { @Override//from w ww . j a v a 2 s .co m public boolean apply(URI key) { return key.toString().startsWith(keyPrefix.toString()); } }); }
From source file:ca.cutterslade.match.scheduler.Tier.java
public Iterable<Match> getMatches(Iterable<Match> matches) { return Iterables.filter(matches, matchPredicate); }