List of usage examples for com.google.common.collect Collections2 filter
@CheckReturnValue public static <E> Collection<E> filter(Collection<E> unfiltered, Predicate<? super E> predicate)
From source file:vars.annotation.ui.imagepanel.JXNotSelectedAreaMeasurementPainter.java
/** * * @param event// w ww.j a v a 2 s. c o m */ @EventSubscriber(eventClass = IAFRepaintEvent.class) public void respondTo(IAFRepaintEvent event) { UIDataCoordinator dataCoordinator = event.get(); Set<Observation> observations = new HashSet<Observation>(dataCoordinator.getObservations()); observations.removeAll(dataCoordinator.getSelectedObservations()); // Search for all observations with area measurements List<Association> associations = new ArrayList<Association>(); for (Observation obs : observations) { associations.addAll(obs.getAssociations()); } Collection<Association> amAssociations = Collections2.filter(associations, AreaMeasurement.IS_AREA_MEASUREMENT_PREDICATE); setAssociations(amAssociations); }
From source file:org.apache.ctakes.assertion.attributes.features.selection.FeatureSelection.java
@Override public Instance<OUTCOME_T> transform(Instance<OUTCOME_T> instance) { List<Feature> features = new ArrayList<Feature>(); for (Feature feature : instance.getFeatures()) { if (this.isTransformable(feature)) { // Filter down to selected features features.addAll(Collections2.filter(((TransformableFeature) feature).getFeatures(), this)); } else {// w ww .j a va 2 s .c o m // Pass non-relevant features through w/o filtering features.add(feature); } } return new Instance<OUTCOME_T>(instance.getOutcome(), features); }
From source file:net.shibboleth.idp.session.logic.LogoutPropagationFlowDescriptorSelector.java
/** * Constructor./*from w ww. j av a 2 s .c om*/ * * @param flows the logout propagation flows to select from */ public LogoutPropagationFlowDescriptorSelector( @Nonnull @NonnullElements final List<LogoutPropagationFlowDescriptor> flows) { Constraint.isNotNull(flows, "Flows cannot be null"); availableFlows = new ArrayList<>(Collections2.filter(flows, Predicates.notNull())); }
From source file:com.notifier.desktop.transport.usb.impl.UsbPortForwarder.java
@Override public void run() { logger.trace("Listing adb devices"); Collection<Adb.Device> actualDevices = Collections.emptyList(); try {/* ww w . j a va2s . c o m*/ List<Adb.Device> devices = adb.devices(); purgeDisconnectedDevices(devices); actualDevices = Collections2.filter(devices, new Adb.Device.TypePredicate(Adb.Device.Type.DEVICE)); actualDevices = Collections2.filter(actualDevices, new Predicate<Adb.Device>() { public boolean apply(Adb.Device input) { return !devicesAndListeners.keySet().contains(input); } }); } catch (IOException e) { logger.error("Error running adb", e); } catch (InterruptedException e) { return; } catch (Exception e) { logger.error("Error running adb", e); } if (!actualDevices.isEmpty()) { logger.debug("Found [{}] new device(s)", actualDevices.size()); for (Adb.Device device : actualDevices) { try { forwardAndListen(device); } catch (InterruptedException e) { return; } catch (Exception e) { logger.error("Error forwarding port for device [" + device.getSerialNumber() + "]", e); } } } }
From source file:com.shigengyu.hyperion.core.TransitionExecutionResult.java
public final Collection<TransitionExecutionLog> getErrors() { return Collections2.filter(logs, new Predicate<TransitionExecutionLog>() { @Override// w w w . j a va 2 s .co m public boolean apply(TransitionExecutionLog item) { return item.getType() == Type.ERROR; } }); }
From source file:edu.umn.msi.tropix.persistence.service.impl.SearchServiceImpl.java
public Collection<TropixObject> getChildren(final String userId, final String objectId) { final TropixObject object = getTropixObjectDao().loadTropixObject(objectId); return Collections2.filter(ModelUtils.getChildren(object), Predicates.getValidAndCanReadPredicate(getSecurityProvider(), userId)); }
From source file:fi.vm.sade.osoitepalvelu.kooste.common.util.CollectionHelper.java
/** * @param original function, result of which to filter * @param filter to apply to function results * @param <E>/* w w w. ja v a 2 s . c o m*/ * @param <T> * @param <C> * @return a function that wraps the given original function in a function that filters the result of it with * given filter */ public static <E, T, C extends List<T>> Function<E, List<T>> filter(final Function<E, C> original, final Predicate<T> filter) { return new Function<E, List<T>>() { public List<T> apply(E input) { return new ArrayList<T>(Collections2.filter(original.apply(input), filter)); } }; }
From source file:com.github.rinde.rinsim.core.model.road.RoadModels.java
/** * Convenience method for {@link Graphs#findClosestObject}. * @param pos The {@link Point} which is used as reference. * @param rm The {@link RoadModel} which is searched. * @param predicate A {@link Predicate} indicating which objects are included * in the search./* w w w. ja v a 2 s .com*/ * @return The closest object in <code>rm</code> to <code>pos</code> which * satisfies the <code>predicate</code>. * @see Graphs#findClosestObject */ @Nullable public static RoadUser findClosestObject(Point pos, RoadModel rm, Predicate<RoadUser> predicate) { final Collection<RoadUser> filtered = Collections2.filter(rm.getObjects(), predicate); return findClosestObject(pos, rm, filtered); }
From source file:rabbit.ui.internal.util.CategoryProvider.java
@Override public Collection<ICategory> getUnselected() { return Collections2.filter(getAllSupported(), not(in(getSelected()))); }
From source file:org.artifactory.common.wicket.component.file.path.RepoPathHelper.java
public Collection<String> getPaths(String repoPath, PathMask mask) { if (repoKey == null || repoPath == null) return Collections.emptyList(); String parentPath = getFilePath(repoPath); final String element = getFileName(repoPath); RepoPath parent = RepoPathFactory.create(repoKey, parentPath); List<ItemInfo> children = repositoryService.getChildren(parent); Collection<ItemInfo> filtered = Collections2.filter(children, new Predicate<ItemInfo>() { @Override/*from w w w.j a v a 2s . c om*/ public boolean apply(@Nullable ItemInfo item) { return element.isEmpty() || (item != null && item.getName().startsWith(element)); } }); return Collections2.transform(filtered, new Function<ItemInfo, String>() { @Nullable @Override public String apply(@Nullable ItemInfo input) { if (input != null) { return input.isFolder() ? input.getRelPath() + "/" : input.getRelPath(); } else { return ""; } } }); }