Java Code Examples for com.google.common.collect.Iterables#removeAll()
The following examples show how to use
com.google.common.collect.Iterables#removeAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Guava.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@ExpectWarning(value="GC", num=5) public static void testIterables(Iterable<String> i, Collection<Integer> c) { Iterables.contains(i, 1); Iterables.removeAll(i, c); Iterables.retainAll(i, c); Iterables.elementsEqual(i, c); Iterables.frequency(i, 1); }
Example 2
Source File: Guava.java From spotbugs with GNU Lesser General Public License v2.1 | 5 votes |
@NoWarning("GC") public static void testIterablesOK(Iterable<String> i, Collection<String> c) { Iterables.contains(i, "x"); Iterables.removeAll(i, c); Iterables.retainAll(i, c); Iterables.elementsEqual(i, c); Iterables.frequency(i, "x"); }
Example 3
Source File: JcloudsLocationSecurityGroupCustomizer.java From brooklyn-server with Apache License 2.0 | 5 votes |
/** * Applies the given security group permissions to the given node with the given compute service. * <p> * Takes no action if the compute service does not have a security group extension. * @param permissions The set of permissions to be applied to the node * @param location */ private Map<String, SecurityGroup> addPermissionsInternal(Iterable<IpPermission> permissions, JcloudsMachineLocation location) { String nodeId = location.getNode().getId(); final Location nodeLocation = location.getNode().getLocation(); ComputeService computeService = location.getParent().getComputeService(); final Optional<SecurityGroupExtension> securityApi = computeService.getSecurityGroupExtension(); if (!securityApi.isPresent()) { LOG.warn("Security group extension for {} absent; cannot update node {} with {}", new Object[] {computeService, nodeId, permissions}); return ImmutableMap.of(); } final SecurityGroupEditor groupEditor = createSecurityGroupEditor(securityApi.get(), nodeLocation); // Expect to have two security groups on the node: one shared between all nodes in the location, // that is cached in sharedGroupCache, and one created by Jclouds that is unique to the node. // Relies on customize having been called before. This should be safe because the arguments // needed to call this method are not available until post-instance creation. String locationId = computeService.getContext().unwrap().getId(); SecurityGroup machineUniqueSecurityGroup = getMachineUniqueSecurityGroup(nodeId, locationId, groupEditor); MutableList<IpPermission> newPermissions = MutableList.copyOf(permissions); Iterables.removeAll(newPermissions, machineUniqueSecurityGroup.getIpPermissions()); machineUniqueSecurityGroup = groupEditor.addPermissions(machineUniqueSecurityGroup, newPermissions); return MutableMap.of(machineUniqueSecurityGroup.getId(), machineUniqueSecurityGroup); }
Example 4
Source File: TaskManager.java From Singularity with Apache License 2.0 | 5 votes |
private List<SingularityTaskId> getTaskIdsForRequest( String requestId, TaskFilter taskFilter ) { final List<SingularityTaskId> requestTaskIds = getTaskIdsForRequest(requestId); final List<SingularityTaskId> activeTaskIds = filterActiveTaskIds(requestTaskIds); if (taskFilter == TaskFilter.ACTIVE) { return activeTaskIds; } Iterables.removeAll(requestTaskIds, activeTaskIds); return requestTaskIds; }
Example 5
Source File: CollectionExtensions.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * Removes all of the specified elements from the specified collection. * * @param collection * the collection from which the {@code elements} are to be removed. May not be <code>null</code>. * @param elements * the elements to remove from the {@code collection}. May not be <code>null</code> but may contain * <code>null</code> entries if the {@code collection} allows that. * @return <code>true</code> if the collection changed as a result of the call * @since 2.4 */ @Inline(value="$3.$4removeAll($1, $2)", imported=Iterables.class) public static <T> boolean removeAll(Collection<T> collection, Collection<? extends T> elements) { return Iterables.removeAll(collection, elements); }
Example 6
Source File: CollectionExtensions.java From xtext-lib with Eclipse Public License 2.0 | 2 votes |
/** * Removes all of the specified elements from the specified collection. * * @param collection * the collection from which the {@code elements} are to be removed. May not be <code>null</code>. * @param elements * the elements to remove from the {@code collection}. May not be <code>null</code> but may contain * <code>null</code> entries if the {@code collection} allows that. * @return <code>true</code> if the collection changed as a result of the call * @since 2.4 */ public static <T> boolean removeAll(Collection<T> collection, Iterable<? extends T> elements) { return Iterables.removeAll(collection, newHashSet(elements)); }