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:com.pidoco.juri.JURI.java

public JURI replaceQueryParameter(String name, String unencodedValue) {
    startChange();//from  ww w.ja  v  a2s  . c o m

    Multimap<String, String> params = getQueryParametersMultimap();
    params.removeAll(name);
    params.put(name, unencodedValue);

    changed();
    return this;
}

From source file:com.pidoco.juri.JURI.java

public JURI replaceQueryParameters(String name, Collection<String> unencodedValues) {
    startChange();//from w  w w .j  a v a  2  s.c om

    Multimap<String, String> params = getQueryParametersMultimap();
    params.removeAll(name);
    params.putAll(name, unencodedValues);

    changed();
    return this;
}

From source file:org.splevo.vpm.analyzer.DefaultVPMAnalyzerService.java

/**
 * Merge buckets and update inverted index for the merged VPs.
 *
 * If the bucket identifying keys are the same, nothing will be performed.
 *
 * @param vpBuckets/*from w  w w  . j a v a2  s .com*/
 *            The buckets of variation points that can be merged.
 * @param vp1
 *            The first vp to check the buckets for.
 * @param mergInKey
 *            The second vp to check the buckets for.
 * @param invertedBucketIndex
 *            The index to update.
 * @return The surviving key.
 */
private VariationPoint mergeBuckets(Multimap<VariationPoint, VariationPoint> vpBuckets,
        VariationPoint survivingKey, VariationPoint mergInKey,
        Map<VariationPoint, VariationPoint> invertedBucketIndex) {

    if (survivingKey == mergInKey) {
        return survivingKey;
    }

    Collection<VariationPoint> mergeInVPs = vpBuckets.get(mergInKey);
    for (VariationPoint mergeInVP : mergeInVPs) {
        invertedBucketIndex.put(mergeInVP, survivingKey);
    }

    vpBuckets.get(survivingKey).addAll(mergeInVPs);
    vpBuckets.removeAll(mergInKey);

    return survivingKey;
}

From source file:edu.uci.ics.sourcerer.tools.java.component.identifier.internal.ClusterIdentifier.java

public static ClusterCollection identifyFullyMatchingClusters(JarCollection jars) {
    TaskProgressLogger task = TaskProgressLogger.get();

    task.start("Identifying fully matching clusters in " + jars.size() + " jar files");

    Multimap<VersionedFqnNode, Cluster> clusterMap = ArrayListMultimap.create();

    // Explore the tree in post-order
    for (VersionedFqnNode parent : jars.getRoot().getPostOrderIterable()) {
        // If it's a leaf, then it starts out as a trivial cluster
        if (!parent.hasChildren()) {
            clusterMap.put(parent, Cluster.create(parent));
        }/*from w  w  w .  j a va2s  .co m*/
        // If it has children, see what children always co-occur
        else {
            // Check if the node itself should be a cluster
            if (parent.getJars().size() > 0) {
                clusterMap.put(parent, Cluster.create(parent));
            }
            for (VersionedFqnNode child : parent.getChildren()) {
                // Match the clusters from the children with the current clusters for this node
                for (Cluster childCluster : clusterMap.get(child)) {
                    Cluster match = null;
                    // Which clusters have already been found for this fragment?
                    for (Cluster parentCluster : clusterMap.get(parent)) {
                        if (areFullyCompatible(childCluster, parentCluster)) {
                            // We found a match!
                            match = parentCluster;
                            // There can be only one, so break
                            break;
                        }
                    }
                    // If we found a match, merge
                    if (match != null) {
                        match.mergeCore(childCluster);
                    }
                    // Otherwise, promote the cluster
                    else {
                        clusterMap.put(parent, childCluster);
                    }
                }
                clusterMap.removeAll(child);
            }
        }
    }

    ClusterCollection clusters = ClusterCollection.create(clusterMap.get(jars.getRoot()));

    task.report("Identified " + clusters.size() + " fully matching clusters");

    task.finish();

    return clusters;
}

From source file:org.eclipse.xtext.scoping.impl.ImportScope.java

protected Iterable<IEObjectDescription> getAliasedElements(Iterable<IEObjectDescription> candidates) {
    Multimap<QualifiedName, IEObjectDescription> keyToDescription = LinkedHashMultimap.create();
    Multimap<QualifiedName, ImportNormalizer> keyToNormalizer = HashMultimap.create();

    for (IEObjectDescription imported : candidates) {
        QualifiedName fullyQualifiedName = imported.getName();
        for (ImportNormalizer normalizer : normalizers) {
            QualifiedName alias = normalizer.deresolve(fullyQualifiedName);
            if (alias != null) {
                QualifiedName key = alias;
                if (isIgnoreCase()) {
                    key = key.toLowerCase();
                }/*from   w  ww . ja v  a 2  s .  c  o m*/
                keyToDescription.put(key, new AliasedEObjectDescription(alias, imported));
                keyToNormalizer.put(key, normalizer);
            }
        }
    }
    for (QualifiedName name : keyToNormalizer.keySet()) {
        if (keyToNormalizer.get(name).size() > 1)
            keyToDescription.removeAll(name);
    }
    return keyToDescription.values();
}

From source file:org.axdt.as3.scoping.As3ImportScope.java

@Override
protected Iterable<IEObjectDescription> getAliasedElements(Iterable<IEObjectDescription> candidates) {
    Multimap<QualifiedName, IEObjectDescription> keyToDescription = LinkedHashMultimap.create();
    Multimap<QualifiedName, ImportNormalizer> keyToNormalizer = HashMultimap.create();

    for (IEObjectDescription imported : candidates) {
        QualifiedName fullyQualifiedName = imported.getName();
        for (ImportNormalizer normalizer : normalizers) {
            QualifiedName alias = normalizer.deresolve(fullyQualifiedName);
            // XXX: dont use relative namespaces
            if (alias != null && alias.getSegmentCount() == 1) {
                QualifiedName key = alias;
                if (isIgnoreCase()) {
                    key = key.toLowerCase();
                }//from   w  w  w  .  j  a  v a2  s.  c  o  m
                keyToDescription.put(key, new AliasedEObjectDescription(alias, imported));
                keyToNormalizer.put(key, normalizer);
            }
        }
    }
    for (QualifiedName name : keyToNormalizer.keySet()) {
        if (keyToNormalizer.get(name).size() > 1)
            keyToDescription.removeAll(name);
    }
    return keyToDescription.values();
}

From source file:com.pidoco.juri.JURI.java

public JURI replaceQueryParameters(Map<String, String> params) {
    startChange();//from   w w  w. j a  va 2 s  .c  om

    Multimap<String, String> queryParameters = getQueryParametersMultimap();
    for (Map.Entry<String, String> entry : params.entrySet()) {
        queryParameters.removeAll(entry.getKey());
        queryParameters.put(entry.getKey(), entry.getValue());
    }

    changed();
    return this;
}

From source file:com.pidoco.juri.JURI.java

public JURI replaceQueryParametersMulti(Map<String, Collection<String>> params) {
    startChange();/*  w ww .j  a  v  a 2s  .  c  o  m*/

    Multimap<String, String> queryParameters = getQueryParametersMultimap();
    for (Map.Entry<String, Collection<String>> entry : params.entrySet()) {
        queryParameters.removeAll(entry.getKey());
        queryParameters.putAll(entry.getKey(), entry.getValue());
    }

    changed();
    return this;
}

From source file:org.geogit.api.RevTreeBuilder.java

/**
 * @return//ww w  .  j a  va 2  s .  c  o m
 * 
 */
private RevTree normalizeToBuckets() {
    // update all inner trees
    final ImmutableSet<Integer> changedBucketIndexes;

    // aggregate size delta for all changed buckets
    long sizeDelta = 0L;
    // aggregate number of trees delta for all changed buckets
    int treesDelta = 0;

    try {
        Multimap<Integer, Node> changesByBucket = getChangesByBucket();
        Preconditions.checkState(featureChanges.isEmpty());
        Preconditions.checkState(treeChanges.isEmpty());
        Preconditions.checkState(deletes.isEmpty());

        changedBucketIndexes = ImmutableSet.copyOf(changesByBucket.keySet());

        for (Integer bucketIndex : changedBucketIndexes) {
            final RevTree currentBucketTree = getBucketTree(bucketIndex);
            final int bucketDepth = this.depth + 1;
            final RevTreeBuilder bucketTreeBuilder = new RevTreeBuilder(this.db, currentBucketTree, bucketDepth,
                    this.pendingWritesCache);
            {
                final Collection<Node> bucketEntries = changesByBucket.removeAll(bucketIndex);
                for (Node node : bucketEntries) {
                    if (node.getObjectId().isNull()) {
                        bucketTreeBuilder.remove(node.getName());
                    } else {
                        bucketTreeBuilder.put(node);
                    }
                }
            }
            final RevTree modifiedBucketTree = bucketTreeBuilder.build();
            final long bucketSizeDelta = modifiedBucketTree.size() - currentBucketTree.size();
            final int bucketTreesDelta = modifiedBucketTree.numTrees() - currentBucketTree.numTrees();
            sizeDelta += bucketSizeDelta;
            treesDelta += bucketTreesDelta;
            if (modifiedBucketTree.isEmpty()) {
                bucketTreesByBucket.remove(bucketIndex);
            } else {
                final Bucket currBucket = this.bucketTreesByBucket.get(bucketIndex);
                if (currBucket == null || !currBucket.id().equals(modifiedBucketTree.getId())) {
                    // have it on the pending writes set only if its not a leaf tree. Non bucket
                    // trees may be too large and cause OOM
                    if (null != pendingWritesCache.remove(currentBucketTree.getId())) {
                        System.err.printf(" ---> removed bucket %s from list\n", currentBucketTree.getId());
                    }
                    if (modifiedBucketTree.buckets().isPresent()) {
                        pendingWritesCache.put(modifiedBucketTree.getId(), modifiedBucketTree);
                    } else {
                        // System.err.println("saving " + modifiedBucketTree);
                        boolean isNew = db.put(modifiedBucketTree);
                    }
                    Envelope bucketBounds = SpatialOps.boundsOf(modifiedBucketTree);
                    Bucket bucket = Bucket.create(modifiedBucketTree.getId(), bucketBounds);
                    bucketTreesByBucket.put(bucketIndex, bucket);
                }
            }
        }
    } catch (RuntimeException e) {
        throw e;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    // compute final size and number of trees out of the aggregate deltas
    long accSize = sizeDelta;
    if (initialSize > RevTree.NORMALIZED_SIZE_LIMIT) {
        accSize += initialSize;
    }
    int accChildTreeCount = this.initialNumTrees + treesDelta;

    return RevTreeImpl.createNodeTree(ObjectId.NULL, accSize, accChildTreeCount, this.bucketTreesByBucket);
}

From source file:com.google.errorprone.bugpatterns.FunctionalInterfaceClash.java

@Override
public Description matchClass(ClassTree tree, VisitorState state) {
    ClassSymbol origin = getSymbol(tree);
    Types types = state.getTypes();
    // collect declared and inherited methods whose signature contains a functional interface
    Multimap<String, MethodSymbol> methods = HashMultimap.create();
    for (Symbol sym : types.membersClosure(getType(tree), /*skipInterface=*/ false).getSymbols()) {
        if (!(sym instanceof MethodSymbol)) {
            continue;
        }/*from   www. j  a  v  a2  s . c  o m*/
        MethodSymbol msym = (MethodSymbol) sym;
        if (msym.getParameters().stream().noneMatch(p -> maybeFunctionalInterface(p.type, types))) {
            continue;
        }
        if (msym.isConstructor() && !msym.owner.equals(origin)) {
            continue;
        }
        methods.put(functionalInterfaceSignature(state, msym), msym);
    }
    // check if any declared members clash with another declared or inherited member
    // (don't report clashes between inherited members)
    for (Tree member : tree.getMembers()) {
        if (!(member instanceof MethodTree)) {
            continue;
        }
        MethodSymbol msym = getSymbol((MethodTree) member);
        if (msym.getParameters().stream().noneMatch(p -> maybeFunctionalInterface(p.type, types))) {
            continue;
        }
        Collection<MethodSymbol> clash = new ArrayList<>(
                methods.removeAll(functionalInterfaceSignature(state, msym)));
        clash.remove(msym);
        // ignore inherited methods that are overridden in the original class
        clash.removeIf(m -> msym.overrides(m, origin, types, false));
        if (!clash.isEmpty()) {
            String message = "When passing lambda arguments to this function, callers will need a cast to"
                    + " disambiguate with: " + clash.stream()
                            .map(m -> Signatures.prettyMethodSignature(origin, m)).collect(joining("\n    "));
            state.reportMatch(buildDescription(member).setMessage(message).build());
        }
    }
    return NO_MATCH;
}