List of usage examples for com.google.common.collect Sets filter
@GwtIncompatible("NavigableSet") @SuppressWarnings("unchecked") @CheckReturnValue public static <E> NavigableSet<E> filter(NavigableSet<E> unfiltered, Predicate<? super E> predicate)
From source file:dtos.conversion.ConverterModule.java
private Set<Class<? extends DtoConverter>> findConverters() { String conversionPackage = configuration.getString("colosseum.conversion.package"); String convertersPackage = configuration.getString("colosseum.conversion.converters"); checkState(conversionPackage != null && convertersPackage != null); Reflections reflections = new Reflections(new ConfigurationBuilder().addClassLoader(classLoader) .setUrls(ClasspathHelper.forPackage(conversionPackage)).addScanners(new SubTypesScanner())); return Sets.filter(reflections.getSubTypesOf(DtoConverter.class), aClass -> aClass.getName().startsWith(convertersPackage)); }
From source file:org.atlasapi.media.entity.Item.java
public Set<Version> nativeVersions() { return Sets.filter(versions, new Predicate<Version>() { @Override/* w ww. j a va 2 s .c o m*/ public boolean apply(Version v) { return publisher.equals(v.getProvider()); } }); }
From source file:org.thiesen.collections.set.impl.AbstractDelegatingMutableSet.java
@Override public IMutableSetView<E> filter(final Predicate<E> predicate) { return SetViews.asIMutableSetView(Sets.filter(_delegate, predicate)); }
From source file:org.thiesen.collections.set.impl.AbstractDelegatingImmutableSet.java
@Override public IImmutableSetView<E> filter(final Predicate<E> predicate) { return SetViews.asIImmutableSetView(Sets.filter(_set, predicate)); }
From source file:org.zanata.model.HPerson.java
@Transient public Set<HProject> getMaintainerProjects() { Set<HProjectMember> maintainerMemberships = Sets.filter(getProjectMemberships(), HProjectMember.IS_MAINTAINER); Collection<HProject> projects = Collections2.transform(maintainerMemberships, HProjectMember.TO_PROJECT); return ImmutableSet.copyOf(projects); }
From source file:eu.lp0.cursus.scoring.scores.base.AbstractScores.java
public AbstractScores(Set<Pilot> pilots, List<Race> races, Set<Event> events, Predicate<Pilot> fleetFilter, ScoresFactory scoresFactory, Scorer scorer) { this.pilots = ImmutableSet.copyOf(pilots); this.races = ImmutableList.copyOf(races); this.scoresFactory = scoresFactory; this.scorer = scorer.getUUID(); Preconditions.checkArgument(!this.pilots.isEmpty(), "No pilots"); //$NON-NLS-1$ Preconditions.checkArgument(!this.races.isEmpty(), "No races"); //$NON-NLS-1$ Set<Series> checkSeries = new HashSet<Series>(2); for (Pilot pilot : pilots) { checkSeries.add(pilot.getSeries()); }/*from ww w . j a v a2 s .com*/ for (Race race : races) { checkSeries.add(race.getEvent().getSeries()); } Preconditions.checkArgument(checkSeries.size() == 1, "Multiple series not allowed"); //$NON-NLS-1$ series = checkSeries.iterator().next(); // Implicitly add events from the races to the set of events Set<Event> raceEvents = new HashSet<Event>(series.getEvents().size() * 2); for (Race race : races) { raceEvents.add(race.getEvent()); } this.events = ImmutableSet.copyOf(Sets.union(events, raceEvents)); fleet = ImmutableSet.copyOf(Sets.filter(series.getPilots(), fleetFilter)); }
From source file:org.locationtech.geogig.model.internal.CachingDAGStorageProvider.java
@Override public List<DAG> getTrees(Set<TreeId> ids) { List<DAG> cached = heap.getTrees(Sets.filter(ids, heapTrees)); List<DAG> res = cached; if (disk != null && cached.size() < ids.size()) { List<DAG> stored = disk.getTrees(Sets.filter(ids, diskTrees)); res.addAll(stored);/*from w w w . ja va 2 s. c o m*/ } return res; }
From source file:com.axemblr.provisionr.cloudstack.core.VirtualMachines.java
private static VirtualMachine getVirtualMachineByName(CloudStackClient client, final String vmName) { Set<VirtualMachine> machines = Sets.filter(client.getVirtualMachineClient().listVirtualMachines( ListVirtualMachinesOptions.Builder.name(vmName)), new Predicate<VirtualMachine>() { @Override//from w w w. j a v a 2 s . c o m public boolean apply(VirtualMachine input) { return vmName.equals(input.getDisplayName()); } }); return Iterables.getOnlyElement(machines); }
From source file:com.censoredsoftware.infractions.bukkit.issuer.Issuer.java
/** * Set of all issued/created Infractions. * * @return Infractions.//from w w w. j a va2 s .c o m */ public Set<Infraction> getIssuedInfractions() { return Sets.filter(Infractions.allInfractions(), new Predicate<Infraction>() { @Override public boolean apply(Infraction infraction) { return getId().equals(infraction.getIssuer().getId()); } }); }
From source file:org.locationtech.geogig.storage.memory.HeapBlobStore.java
@Override public void removeBlobs(final String namespace) { Set<String> all = ImmutableSet.copyOf(blobs.keySet()); Set<String> filtered = Sets.filter(all, new Predicate<String>() { final String prefix = namespace + "/"; @Override/*from w ww . jav a 2 s . c o m*/ public boolean apply(String key) { return key.startsWith(prefix); } }); for (String k : filtered) { blobs.remove(k); } }