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

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

Introduction

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

Prototype

@Override
Set<V> removeAll(@Nullable Object key);

Source Link

Document

Because a SetMultimap has unique values for a given key, this method returns a Set , instead of the java.util.Collection specified in the Multimap interface.

Usage

From source file:org.jboss.capedwarf.search.RemoveFieldsTask.java

protected Void execute(SetMultimap<String, Field.FieldType> map) {
    if (map != null) {
        for (String fieldName : fields) {
            map.removeAll(fieldName);
        }/*from w w  w  .  j  a va  2s .  c om*/
    }

    return null;
}

From source file:io.usethesource.criterion.impl.immutable.guava.ImmutableGuavaSetMultimap.java

@Override
public JmhSetMultimap remove(JmhValue key) {
    final SetMultimap<JmhValue, JmhValue> tmpContent = HashMultimap.create(content);
    tmpContent.removeAll(key);

    final ImmutableSetMultimap<JmhValue, JmhValue> newContent = ImmutableSetMultimap.copyOf(tmpContent);

    return new ImmutableGuavaSetMultimap(newContent);
}

From source file:io.usethesource.criterion.impl.immutable.guava.ImmutableGuavaSetMultimap.java

@Override
public JmhSetMultimap put(JmhValue key, JmhValue value) {
    final SetMultimap<JmhValue, JmhValue> tmpContent = HashMultimap.create(content);
    tmpContent.removeAll(key);
    tmpContent.put(key, value);//  www  .  j a v  a 2s . co m

    final ImmutableSetMultimap<JmhValue, JmhValue> newContent = ImmutableSetMultimap.copyOf(tmpContent);

    return new ImmutableGuavaSetMultimap(newContent);
}

From source file:dagger.internal.codegen.ComponentHierarchyValidator.java

/**
 * Checks that components do not have any scopes that are also applied on any of their ancestors.
 */// ww w.  ja v a  2s . co m
private void validateScopeHierarchy(ValidationReport.Builder<TypeElement> report, ComponentDescriptor subject,
        SetMultimap<ComponentDescriptor, Scope> scopesByComponent) {
    scopesByComponent.putAll(subject, subject.scopes());

    for (ComponentDescriptor child : subject.subcomponents()) {
        validateScopeHierarchy(report, child, scopesByComponent);
    }

    scopesByComponent.removeAll(subject);

    Predicate<Scope> subjectScopes = subject.kind().isProducer()
            // TODO(beder): validate that @ProductionScope is only applied on production components
            ? and(in(subject.scopes()), not(equalTo(Scope.productionScope(elements))))
            : in(subject.scopes());
    SetMultimap<ComponentDescriptor, Scope> overlappingScopes = Multimaps.filterValues(scopesByComponent,
            subjectScopes);
    if (!overlappingScopes.isEmpty()) {
        StringBuilder error = new StringBuilder().append(subject.componentDefinitionType().getQualifiedName())
                .append(" has conflicting scopes:");
        for (Map.Entry<ComponentDescriptor, Scope> entry : overlappingScopes.entries()) {
            Scope scope = entry.getValue();
            error.append("\n  ").append(entry.getKey().componentDefinitionType().getQualifiedName())
                    .append(" also has ").append(scope.getReadableSource());
        }
        report.addItem(error.toString(), compilerOptions.scopeCycleValidationType().diagnosticKind().get(),
                subject.componentDefinitionType());
    }
}

From source file:org.robotframework.ide.eclipse.main.plugin.model.RobotSuiteFile.java

public SetMultimap<LibrarySpecification, String> getImportedLibraries() {
    final Optional<RobotSettingsSection> section = findSection(RobotSettingsSection.class);
    final SetMultimap<String, String> toImport = HashMultimap.create();
    if (section.isPresent()) {
        toImport.putAll(section.get().getLibrariesPathsOrNamesWithAliases());
    }/*from   w w w.j  a va2 s  .com*/

    final SetMultimap<LibrarySpecification, String> imported = HashMultimap.create();
    for (final LibrarySpecification spec : getProject().getLibrariesSpecifications()) {
        if (toImport.containsKey(spec.getName())) {
            imported.putAll(spec, toImport.get(spec.getName()));
            toImport.removeAll(spec.getName());
        } else if (spec.isAccessibleWithoutImport()) {
            imported.put(spec, "");
        }
    }
    for (final String toImportPathOrName : toImport.keySet()) {
        try {
            final LibrarySpecification spec = findSpecForPath(toImportPathOrName);
            if (spec != null) {
                imported.putAll(spec, toImport.get(toImportPathOrName));
            }
        } catch (final PathResolvingException e) {
            // ok we won't provide any spec, since we can't resolve uri
        }
    }
    return imported;
}

From source file:com.android.build.gradle.shrinker.IncrementalShrinker.java

/**
 * Decides which classes need to be updated on disk and which need to be deleted. It puts
 * appropriate entries in the lists passed as arguments.
 *//*from w ww . j a  v  a  2s  .  c om*/
private void chooseClassesToWrite(@NonNull Iterable<TransformInput> inputs,
        @NonNull TransformOutputProvider output, @NonNull Collection<T> classesToWrite,
        @NonNull Collection<File> classFilesToDelete, @NonNull SetMultimap<T, String> oldState) {
    for (T klass : mGraph.getReachableClasses(CounterSet.SHRINK)) {
        if (!oldState.containsKey(klass)) {
            classesToWrite.add(klass);
        } else {
            Set<String> newMembers = mGraph.getReachableMembersLocalNames(klass, CounterSet.SHRINK);
            Set<String> oldMembers = oldState.get(klass);

            // Reverse of the trick above, where we store one artificial member for empty
            // classes.
            if (oldMembers.size() == 1) {
                oldMembers.remove(mGraph.getClassName(klass));
            }

            if (!newMembers.equals(oldMembers)) {
                classesToWrite.add(klass);
            }
        }

        oldState.removeAll(klass);
    }

    // All keys that remained in oldState should be deleted.
    for (T klass : oldState.keySet()) {
        File sourceFile = mGraph.getSourceFile(klass);
        checkState(sourceFile != null, "One of the inputs has no source file.");

        Optional<File> outputFile = chooseOutputFile(klass, sourceFile, inputs, output);
        if (!outputFile.isPresent()) {
            throw new IllegalStateException("Can't determine path of " + mGraph.getClassName(klass));
        }
        classFilesToDelete.add(outputFile.get());
    }
}

From source file:org.nuxeo.runtime.test.runner.RuntimeFeature.java

/**
 * Deploys bundles specified in the @Bundles annotation.
 *//*from ww w. j a v  a2 s. c  om*/
protected void deployTestClassBundles(FeaturesRunner runner) throws Exception {
    Set<String> bundles = new HashSet<String>();
    Map<String, Collection<String>> mainDeployments = new HashMap<>();
    SetMultimap<String, String> mainIndex = Multimaps.newSetMultimap(mainDeployments,
            new Supplier<Set<String>>() {
                @Override
                public Set<String> get() {
                    return new HashSet<String>();
                }
            });
    Map<String, Collection<String>> localDeployments = new HashMap<>();
    SetMultimap<String, String> localIndex = Multimaps.newSetMultimap(localDeployments,
            new Supplier<Set<String>>() {
                @Override
                public Set<String> get() {
                    return new HashSet<String>();
                }
            });
    indexBundleResources(runner, bundles, mainIndex, getDeployments());
    indexBundleResources(runner, bundles, localIndex, getLocalDeployments());
    AssertionError errors = new AssertionError("cannot deploy components");
    for (String name : bundles) {
        Bundle bundle = null;
        try {
            harness.deployBundle(name);
            bundle = harness.getOSGiAdapter().getBundle(name);
        } catch (Exception error) {
            errors.addSuppressed(error);
            continue;
        }
        try {
            // deploy bundle contribs
            for (String resource : mainIndex.removeAll(name)) {
                try {
                    harness.deployContrib(name, resource);
                } catch (Exception error) {
                    errors.addSuppressed(error);
                }
            }
            // deploy local contribs
            for (String resource : localIndex.removeAll(name)) {
                URL url = runner.getTargetTestResource(name);
                if (url == null) {
                    url = bundle.getEntry(resource);
                }
                if (url == null) {
                    url = runner.getTargetTestClass().getClassLoader().getResource(resource);
                }
                if (url == null) {
                    throw new AssertionError("Cannot find " + resource + " in " + name);
                }
                harness.deployTestContrib(name, url);
            }
        } catch (Exception error) {
            errors.addSuppressed(error);
        }
    }

    for (Map.Entry<String, String> resource : mainIndex.entries()) {
        try {
            harness.deployContrib(resource.getKey(), resource.getValue());
        } catch (Exception error) {
            errors.addSuppressed(error);
        }
    }
    for (Map.Entry<String, String> resource : localIndex.entries()) {
        try {
            harness.deployTestContrib(resource.getKey(), resource.getValue());
        } catch (Exception error) {
            errors.addSuppressed(error);
        }
    }

    if (errors.getSuppressed().length > 0) {
        throw errors;
    }
}