Example usage for com.google.common.collect Iterables filter

List of usage examples for com.google.common.collect Iterables filter

Introduction

In this page you can find the example usage for com.google.common.collect Iterables filter.

Prototype

@GwtIncompatible("Class.isInstance")
@CheckReturnValue
public static <T> Iterable<T> filter(final Iterable<?> unfiltered, final Class<T> desiredType) 

Source Link

Document

Returns all elements in unfiltered that are of the type desiredType .

Usage

From source file:pl.softech.eav.example.SimpleInMemmoryRepository.java

protected E findOne(Predicate<E> predicate) {
    return Iterables.getOnlyElement(Iterables.filter(key2entity.values(), predicate), null);
}

From source file:com.isotrol.impe3.pms.core.impl.AbstractPublishableService.java

static <U extends PublishableEntity<?, ?, ?>> Iterable<U> filterNotDeleted(Iterable<U> entities) {
    return Iterables.filter(entities, EntityFunctions.NOT_DELETED);
}

From source file:org.eclipse.xtext.util.formallang.ProductionStringFactory.java

@Override
public String createForAlternativeChildren(boolean many, boolean optional, Iterable<String> children) {
    List<String> childrenSorted = Lists.newArrayList(Iterables.filter(children, Predicates.notNull()));
    Collections.sort(childrenSorted);
    return "(" + Joiner.on(" | ").join(childrenSorted) + ")" + card(many, optional);
}

From source file:xml.entity.immutableelement.InternalElement.java

@Override
public String value() {
    return Joiner.on("").join(Iterables.filter(children, ImmutableElements.byName("#text")));
}

From source file:org.isisaddons.module.fakedata.dom.IsisClobs.java

private static List<String> fileNamesEndingWith(final String suffix) {
    return Lists.newArrayList(Iterables.filter(IsisClobs.fileNames, endsWith(suffix)));
}

From source file:org.eclipse.emf.eson.scoping.SimpleEPackageScope.java

@Override
public Iterable<IEObjectDescription> getElements(EObject object) {
    Iterable<IEObjectDescription> result = super.getElements(object);
    if (Iterables.isEmpty(result) && (object instanceof EPackage)) {
        final EPackage ePackage = (EPackage) object;
        Iterable<IEObjectDescription> localElements = getLocalElementsByEClass(EcorePackage.Literals.EPACKAGE);
        result = Iterables.filter(localElements, new Predicate<IEObjectDescription>() {
            @Override//from w ww  .  j a va2s  .c  om
            public boolean apply(IEObjectDescription input) {
                return input.getQualifiedName().getFirstSegment().equals(ePackage.getNsURI());
            }
        });
    }
    return result;
}

From source file:org.broad.igv.cli_plugin.ui.TrackArgument.java

public TrackArgument(Argument argument) {
    initComponents();//from w  w w  .  j a  va2  s  .  c o m
    super.initCommon(argument);

    if (argument != null) {
        List<Track> trackList = IGV.getInstance().getAllTracks();

        Class clazz = getTrackClass(argument);
        Iterable<Track> tracks = Iterables.filter(trackList, clazz);
        List<Track> filteredTrackList = Lists.newArrayList(tracks);
        if (filteredTrackList.size() == 0) {
            throw new IllegalStateException("No tracks found of appropriate type; make sure data is loaded");
        }
        trackComboBox.setModel(new DefaultComboBoxModel(filteredTrackList.toArray()));
        trackComboBox.setRenderer(new TrackComboBoxRenderer());
    }
}

From source file:org.gradle.api.internal.artifacts.resolution.DefaultJvmLibrary.java

public Iterable<JvmLibraryJavadocArtifact> getJavadocArtifacts() {
    return Iterables.filter(getAllArtifacts(), JvmLibraryJavadocArtifact.class);
}

From source file:playground.michalm.taxi.schedule.TaxiSchedules.java

public static Iterable<TaxiRequest> getTaxiRequests(Schedule<TaxiTask> schedule) {
    Iterable<TaxiTask> pickupTasks = Iterables.filter(schedule.getTasks(), IS_PICKUP);
    return Iterables.transform(pickupTasks, TAXI_TASK_TO_REQUEST);
}

From source file:suneido.database.immudb.ForeignKeyTargets.java

ForeignKeyTargets without(ForeignKey source, ForeignKeyTarget target) {
    Set<ForeignKeyTarget> cur = targets.get(source);
    ImmutableSet<ForeignKeyTarget> wo = ImmutableSet
            .copyOf(Iterables.filter(cur, Predicates.not(Predicates.equalTo(target))));
    return new ForeignKeyTargets(targets.with(source, wo));
}