List of usage examples for com.google.common.collect Iterators filter
@SuppressWarnings("unchecked") @GwtIncompatible("Class.isInstance") @CheckReturnValue public static <T> UnmodifiableIterator<T> filter(Iterator<?> unfiltered, Class<T> desiredType)
From source file:com.eviware.loadui.impl.reporting.statistics.ChartLegendDataSource.java
@Override public void moveFirst() throws JRException { iterator = Iterators.filter(chartView.getSegments().iterator(), LineSegment.class); }
From source file:org.polymap.core.project.ui.util.SelectionAdapter.java
public <T> Iterator<T> iterator(Class<T> type) { return Iterators.filter(iterator(), type); }
From source file:org.polarsys.reqcycle.export.rmf.transform.RequirementSourceReqProvider.java
@Override public ArrayList<Section> getSections() { return Lists.newArrayList(Iterators.filter(source.getContents().eAllContents(), Section.class)); }
From source file:edu.umd.cs.psl.model.set.membership.SoftMembership.java
@Override public Iterator<A> iterator() { return Iterators.filter(members.keySet().iterator(), new Predicate<A>() { @Override/*from w w w. j av a 2 s . co m*/ public boolean apply(A obj) { return members.get(obj) > 0.0; } }); }
From source file:org.jgrades.lic.service.DateRule.java
private boolean checkExpiredDaysMode(Licence licence) { List<LicenceProperty> properties = licence.getProperties(); UnmodifiableIterator<LicenceProperty> expiredDaysProperty = Iterators.filter(properties.iterator(), licenceProperty -> licenceProperty.getName().equals(EXPIRED_DAYS_PROPERTY_NAME)); LicenceProperty property = null;/*from ww w . j a v a 2 s . co m*/ if (expiredDaysProperty.hasNext()) { property = expiredDaysProperty.next(); } if (Optional.ofNullable(property).isPresent()) { LOGGER.debug("ExpiredDays property found for licence with uid {}", licence.getUid()); int days = Integer.parseInt(property.getValue()); if (licence.getProduct().getValidTo().plusDays(days).isAfter(now())) { LOGGER.debug("Licence with uid {} is in expiredDays period ({} extra days)", licence.getUid(), days); return true; } } else { LOGGER.debug("ExpiredDays property not found for licence with uid {}", licence.getUid()); } return false; }
From source file:com.intelligentsia.dowsers.entity.store.AbstractEntityStore.java
@Override public Iterable<Reference> find(final Reference reference) throws NullPointerException { final Class<?> expectedType = ClassInformation.parse(reference.getEntityClassName()).getType(); // filtering result from find(final Class<?> expectedType) final Iterator<Reference> iterator = Iterators.filter(find(expectedType).iterator(), new Predicate<Reference>() { @Override//from ww w .j ava 2 s. c o m public boolean apply(final Reference input) { final Object object = find(expectedType, input); if (object != null) { final Entity entity = References.discover(object); final Object attribute = entity.attribute(reference.getAttributeName()); if (attribute != null) { return attribute.equals(reference.getIdentity()); } } return false; } }); // return final iterator return new Iterable<Reference>() { @Override public Iterator<Reference> iterator() { return iterator; } }; }
From source file:org.geogit.api.porcelain.CleanOp.java
/** * @see java.util.concurrent.Callable#call() *//*from w ww .j a va 2 s. c o m*/ public WorkingTree call() { if (path != null) { // check that is a valid path NodeRef.checkValidPath(path); Optional<NodeRef> ref = command(FindTreeChild.class).setParent(getWorkTree().getTree()) .setChildPath(path).setIndex(true).call(); Preconditions.checkArgument(ref.isPresent(), "pathspec '%s' did not match any tree", path); Preconditions.checkArgument(ref.get().getType() == TYPE.TREE, "pathspec '%s' did not resolve to a tree", path); } final Iterator<DiffEntry> unstaged = command(DiffWorkTree.class).setFilter(path).call(); final Iterator<DiffEntry> added = Iterators.filter(unstaged, new Predicate<DiffEntry>() { @Override public boolean apply(@Nullable DiffEntry input) { return input.changeType().equals(ChangeType.ADDED); } }); Iterator<String> addedPaths = Iterators.transform(added, new Function<DiffEntry, String>() { @Override public String apply(DiffEntry input) { return input.newPath(); } }); getWorkTree().delete(addedPaths); return getWorkTree(); }
From source file:org.eclipse.sirius.diagram.sequence.business.internal.query.SequenceDiagramDescriptionQuery.java
/** * return any InstanceRoleMapping contained in the diagram having the given * name./*from w ww. j a va 2 s. c om*/ * * @param name * name of the searched element. * @return any InstanceRoleMapping contained in the diagram having the given * name. */ public Iterator<InstanceRoleMapping> getInstanceRoleMappings(final String name) { return Iterators.filter(Iterators.filter(diag.eAllContents(), InstanceRoleMapping.class), new Predicate<InstanceRoleMapping>() { public boolean apply(InstanceRoleMapping input) { return name.equals(input.getName()); } }); }
From source file:test.org.mandarax.compiler.FatherRelRecords2.java
public Iterator<FatherRel> getFather(final String child) { Iterator<FatherRel> iterator = data.iterator(); Predicate<FatherRel> filter = new Predicate<FatherRel>() { @Override//from w w w .ja v a2 s . c o m public boolean apply(FatherRel rel) { return rel.child.equals(child); } }; return Iterators.filter(iterator, filter); }
From source file:uk.ac.ed.inf.ace.processors.CleanTokens.java
@Override public ReadWriteableDocument process(ReadWriteableDocument document) { @SuppressWarnings("unchecked") Iterator<String> tokens = (Iterator<String>) document.getContent(); document.setContent(Iterators.filter(Iterators.transform(tokens, NULL_TO_EMPTY), IS_NOT_EMPTY)); return document; }