Example usage for com.google.common.collect Multimap removeAll

List of usage examples for com.google.common.collect Multimap removeAll

Introduction

In this page you can find the example usage for com.google.common.collect Multimap removeAll.

Prototype

Collection<V> removeAll(@Nullable Object key);

Source Link

Document

Removes all values associated with the key key .

Usage

From source file:org.commoncrawl.service.parser.server.ParserSlaveServer.java

public static void main(String[] args) {
    Multimap<String, String> options = TreeMultimap.create();
    for (int i = 0; i < args.length; ++i) {
        String optionName = args[i];
        if (++i != args.length) {
            String optionValue = args[i];
            options.put(optionName, optionValue);
        }//  www . j  a v a2 s .com
    }
    options.removeAll("--server");
    options.put("--server", ParserSlaveServer.class.getName());

    Collection<Entry<String, String>> entrySet = options.entries();
    String finalArgs[] = new String[entrySet.size() * 2];
    int index = 0;
    for (Entry entry : entrySet) {
        finalArgs[index++] = (String) entry.getKey();
        finalArgs[index++] = (String) entry.getValue();
    }

    try {
        CommonCrawlServer.main(finalArgs);
    } catch (Exception e) {
        LOG.error(CCStringUtils.stringifyException(e));
    }
}

From source file:org.commoncrawl.service.parser.ec2.EC2ParserMaster.java

public static void main(String[] args) throws IOException {

    Multimap<String, String> options = TreeMultimap.create();
    for (int i = 0; i < args.length; ++i) {
        String optionName = args[i];
        if (++i != args.length) {
            String optionValue = args[i];
            options.put(optionName, optionValue);
        }//from   w  w  w  .  j a  v a 2  s .c om
    }
    options.removeAll("--server");
    options.put("--server", EC2ParserMaster.class.getName());

    Collection<Entry<String, String>> entrySet = options.entries();
    String finalArgs[] = new String[entrySet.size() * 2];
    int index = 0;
    for (Entry entry : entrySet) {
        finalArgs[index++] = (String) entry.getKey();
        finalArgs[index++] = (String) entry.getValue();
    }

    try {
        CommonCrawlServer.main(finalArgs);
    } catch (Exception e) {
        LOG.error(CCStringUtils.stringifyException(e));
    }
}

From source file:org.jclouds.http.utils.ModifyRequest.java

@SuppressWarnings("unchecked")
public static <R extends HttpRequest> R removeHeader(R request, String header) {
    Multimap<String, String> headers = LinkedHashMultimap.create(checkNotNull(request, "request").getHeaders());
    headers.removeAll(checkNotNull(header, "header"));
    return (R) request.toBuilder().headers(headers).build();
}

From source file:com.google.devtools.j2objc.translate.TypeSorter.java

public static void sortTypes(CompilationUnit unit) {
    List<AbstractTypeDeclaration> typeNodes = unit.getTypes();
    Map<String, AbstractTypeDeclaration> nodeMap = Maps.newHashMap();
    LinkedHashMap<String, ITypeBinding> bindingMap = Maps.newLinkedHashMap();
    for (AbstractTypeDeclaration node : typeNodes) {
        ITypeBinding typeBinding = node.getTypeBinding();
        String key = typeBinding.getKey();
        nodeMap.put(key, node);//w  ww . j a v  a2  s.  com
        bindingMap.put(key, typeBinding);
    }
    Multimap<String, String> superTypes = findSuperTypes(bindingMap);

    ArrayList<String> rootTypes = Lists.newArrayListWithCapacity(typeNodes.size());
    for (String type : bindingMap.keySet()) {
        if (!superTypes.containsValue(type)) {
            rootTypes.add(type);
        }
    }

    typeNodes.clear();
    while (!rootTypes.isEmpty()) {
        String nextType = rootTypes.remove(rootTypes.size() - 1);
        typeNodes.add(0, nodeMap.get(nextType));
        for (String superType : superTypes.removeAll(nextType)) {
            if (!superTypes.containsValue(superType)) {
                rootTypes.add(superType);
            }
        }
    }
}

From source file:org.ow2.proactive.scheduler.authentication.ManageUsers.java

private static void updateUserGroups(String login, Collection<String> groups,
        Multimap<String, String> groupsMap) {
    if (!groups.isEmpty()) {
        groupsMap.removeAll(login);
        for (String group : groups) {
            if (!group.isEmpty()) {
                groupsMap.put(login, group);
                System.out.println("Adding group " + group + " to user " + login);
            }//  w  w w. java  2 s .  c  o  m
        }
    }
}

From source file:org.openhab.model.script.scoping.ScriptExtensionClassNameProvider.java

@Override
protected Multimap<Class<?>, Class<?>> simpleComputeExtensionClasses() {
    Multimap<Class<?>, Class<?>> result = super.simpleComputeExtensionClasses();
    result.removeAll(Comparable.class);
    result.removeAll(Double.class);
    result.removeAll(Integer.class);
    result.removeAll(BigInteger.class);
    result.removeAll(BigDecimal.class);
    result.removeAll(double.class);
    result.put(Number.class, NumberExtensions.class);
    result.put(Type.class, NumberExtensions.class);
    result.put(Comparable.class, NumberExtensions.class);
    result.put(String.class, StringUtils.class);
    result.put(String.class, URLEncoder.class);
    result.put(Item.class, PersistenceExtensions.class);
    result.put(Item.class, BusEvent.class);
    return result;
}

From source file:com.eucalyptus.util.dns.DnsResolvers.java

@SuppressWarnings("unchecked")
private static void addRRset(Name name, final Message response, Record[] records, final int section) {
    final Multimap<RequestType, Record> rrsets = LinkedHashMultimap.create();
    for (Record r : records) {
        RequestType type = RequestType.typeOf(r.getType());
        rrsets.get(type).addAll(Collections2.filter(Arrays.asList(records), type));
    }//from www.j a  v  a 2s  .c om
    Predicate<Record> checkNewRecord = new Predicate<Record>() {

        @Override
        public boolean apply(Record input) {
            for (int s = 1; s <= section; s++) {
                if (response.findRecord(input, s)) {
                    return false;
                }
            }
            return true;
        }
    };
    if (rrsets.containsKey(RequestType.CNAME)) {
        for (Record cnames : Iterables.filter(rrsets.removeAll(RequestType.CNAME), checkNewRecord)) {
            response.addRecord(cnames, section);
        }
    }
    for (Record sectionRecord : Iterables.filter(rrsets.values(), checkNewRecord)) {
        response.addRecord(sectionRecord, section);
    }
}

From source file:com.isotrol.impe3.core.engine.ImmutableRenderContext.java

public URI getSamePageURI(Set<String> remove, Multimap<String, ?> parameters) {
    final UriBuilder b = UriBuilder.fromUri("");
    if (remove == null || remove.isEmpty()) {
        return getSamePageURI(parameters);
    }//www.j a v  a  2 s. c  o m
    final Multimap<String, ?> qp = ArrayListMultimap.create(query);
    for (String r : remove) {
        qp.removeAll(r);
    }
    URIs.queryParameters(b, qp);
    URIs.queryParameters(b, parameters);
    return b.build();
}

From source file:org.jclouds.cloudstack.filters.QuerySigner.java

@VisibleForTesting
void addSigningParams(Multimap<String, String> params) {
    params.replaceValues("apiKey", ImmutableList.of(creds.get().identity));
    params.removeAll("signature");
}

From source file:org.jclouds.aws.filters.FormSigner.java

@VisibleForTesting
void addSigningParams(Multimap<String, String> params) {
    params.removeAll(SIGNATURE);
    params.removeAll(SECURITY_TOKEN);// w  w w  .j  a v a2 s.co  m
    Credentials current = creds.get();
    if (current instanceof SessionCredentials) {
        params.put(SECURITY_TOKEN, SessionCredentials.class.cast(current).getSessionToken());
    }
    params.replaceValues(SIGNATURE_METHOD, ImmutableList.of("HmacSHA256"));
    params.replaceValues(SIGNATURE_VERSION, ImmutableList.of("2"));
    params.replaceValues(TIMESTAMP, ImmutableList.of(dateService.get()));
    params.replaceValues(AWS_ACCESS_KEY_ID, ImmutableList.of(creds.get().identity));
}