Example usage for com.google.common.collect Sets union

List of usage examples for com.google.common.collect Sets union

Introduction

In this page you can find the example usage for com.google.common.collect Sets union.

Prototype

public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2) 

Source Link

Document

Returns an unmodifiable view of the union of two sets.

Usage

From source file:com.google.caliper.runner.ParameterSet.java

public ImmutableSetMultimap<String, String> fillInDefaultsFor(
        ImmutableSetMultimap<String, String> explicitValues) throws InvalidBenchmarkException {
    ImmutableSetMultimap.Builder<String, String> combined = ImmutableSetMultimap.builder();

    // For user parameters, this'll actually be the same as fromClass.keySet(), since any extras
    // given at the command line are treated as errors; for VM parameters this is not the case.
    for (String name : Sets.union(map.keySet(), explicitValues.keySet())) {
        Parameter parameter = map.get(name);
        ImmutableCollection<String> values = explicitValues.containsKey(name) ? explicitValues.get(name)
                : parameter.defaults();/* ww  w  .j  a  v  a  2 s .c o  m*/

        combined.putAll(name, values);
        if (values.isEmpty()) {
            throw new InvalidBenchmarkException("ERROR: No default value provided for " + name);
        }
    }
    return combined.orderKeysBy(Ordering.natural()).build();
}

From source file:ai.grakn.graql.internal.reasoner.query.ReasonerQueries.java

/**
 * create a reasoner query by combining an existing query and a substitution
 * @param q base query for substitution to be attached
 * @param sub (partial) substitution//from   w w  w.j  a  va 2  s  . com
 * @return reasoner query with the substitution contained in the query
 */
public static ReasonerQueryImpl create(ReasonerQueryImpl q, Answer sub) {
    return create(Sets.union(q.getAtoms(), sub.toPredicates(q)), q.tx());
}

From source file:eu.amidst.core.variables.MissingAssignment.java

/**
 * {@inheritDoc}
 */
@Override
public Set<Variable> getVariables() {
    return Sets.union(assignment.getVariables(), missingVars.keySet());
}

From source file:org.dllearner.core.owl.AbstractHierarchy.java

/**
 * @return all entities in this hierarchy
 */
public Set<T> getEntities() {
    return Sets.union(hierarchyDown.keySet(), hierarchyUp.keySet());
}

From source file:org.eclipse.viatra.query.runtime.localsearch.planner.PlanState.java

public void updateOperations(List<PConstraintInfo> allPotentialExtendInfos,
        List<PConstraintInfo> allPotentialChecks) {
    futureChecks = Lists.newArrayList();
    futureExtends = Lists.newArrayList();
    presentExtends = Lists.newArrayList();

    Set<PConstraintInfo> allUsedAppliedConstraints = Sets.newHashSet();
    for (PConstraintInfo pConstraintPlanInfo : operationsList) {
        allUsedAppliedConstraints = Sets.newHashSet(
                Sets.union(allUsedAppliedConstraints, pConstraintPlanInfo.getSameWithDifferentBindings()));
    }/*w ww.  ja  v  a  2  s.c o  m*/

    final Set<PConstraintInfo> allUsedAppliedConstraintsArg = allUsedAppliedConstraints;

    Collection<PConstraintInfo> allRelevantExtendInfos = Collections2.filter(allPotentialExtendInfos,
            new Predicate<PConstraintInfo>() {

                @Override
                public boolean apply(PConstraintInfo input) {
                    return !allUsedAppliedConstraintsArg.contains(input) && isPossibleExtend(input);
                }
            });
    // categorize extend constraint infos
    categorizeExtends(allRelevantExtendInfos);

    Collection<PConstraintInfo> allRelevantCheckInfos = Collections2.filter(allPotentialChecks,
            new Predicate<PConstraintInfo>() {

                @Override
                public boolean apply(PConstraintInfo input) {
                    return !allUsedAppliedConstraintsArg.contains(input) && isPossibleCheck(input);
                }
            });
    // categorize check constraint infos
    categorizeChecks(allRelevantCheckInfos);

    // sort them by cost
    // TODO this sort is just for sure, most likely it's unnecessary
    OperationCostComparator infoComparator = new OperationCostComparator();

    Collections.sort(futureChecks, infoComparator);
    Collections.sort(futureExtends, infoComparator);
    Collections.sort(presentExtends, infoComparator);
}

From source file:springfox.documentation.spring.web.plugins.CombinedRequestHandler.java

@Override
public Set<? extends MediaType> produces() {
    return Sets.union(first.produces(), second.produces());
}

From source file:org.gradle.api.java.archives.internal.DefaultManifestMergeSpec.java

private DefaultManifest mergeManifest(DefaultManifest baseManifest, DefaultManifest toMergeManifest,
        FileResolver fileResolver) {/*from w ww .  ja v  a 2 s. c  om*/
    DefaultManifest mergedManifest = new DefaultManifest(fileResolver);
    mergeSection(null, mergedManifest, baseManifest.getAttributes(), toMergeManifest.getAttributes());
    Set<String> allSections = Sets.union(baseManifest.getSections().keySet(),
            toMergeManifest.getSections().keySet());
    for (String section : allSections) {
        mergeSection(section, mergedManifest,
                GUtil.elvis(baseManifest.getSections().get(section), new DefaultAttributes()),
                GUtil.elvis(toMergeManifest.getSections().get(section), new DefaultAttributes()));
    }
    return mergedManifest;
}

From source file:co.cask.cdap.logging.appender.LoggingContextMDC.java

@Override
public Set<Entry<String, String>> entrySet() {
    return new AbstractSet<Entry<String, String>>() {
        @Override//w w w  . j  a va 2 s .  c o  m
        public Iterator<Entry<String, String>> iterator() {
            return entryIterable.iterator();
        }

        @Override
        public int size() {
            return Sets.union(systemTags.keySet(), eventMDC.keySet()).size();
        }
    };
}

From source file:org.apache.cassandra.index.sasi.conf.view.PrefixTermTree.java

public Set<SSTableIndex> search(Expression e) {
    Map<ByteBuffer, Set<SSTableIndex>> indexes = (e == null || e.lower == null
            || mode == OnDiskIndexBuilder.Mode.CONTAINS) ? trie : trie.prefixMap(e.lower.value);

    Set<SSTableIndex> view = new HashSet<>(indexes.size());
    indexes.values().forEach(view::addAll);
    return Sets.union(view, super.search(e));
}

From source file:com.github.lukaszkusek.xml.comparator.comparators.attributes.XMLAttributesComparator.java

private Set<String> getAttributesNamesToIterate(Node node1, Node node2) {
    return Sets.union(node1.getAttributesNames(), node2.getAttributesNames());
}