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:org.openqa.selenium.logging.CompositeLocalLogs.java

public Set<String> getAvailableLogTypes() {
    return Sets.union(predefinedTypeLogger.getAvailableLogTypes(), allTypesLogger.getAvailableLogTypes());
}

From source file:io.wcm.caravan.jaxrs.publisher.impl.JaxRsApplication.java

@Override
public Set<Object> getSingletons() {
    return Sets.union(globalComponents, localComponents);
}

From source file:co.turnus.analysis.trace.NearestNeighbor.java

public static Set<Step> find(Set<Step> ancestors, int maxNodes, int maxDegree, String firingAttributeId) {

    Set<Step> successors = new HashSet<>();
    for (Step ancestor : ancestors) {
        for (Dependency out : ancestor.getOutgoings()) {
            Step tgt = out.getTarget();//  w ww .  java2 s  .  c o m
            if (!ancestors.contains(tgt) && !tgt.getAttribute(firingAttributeId, false)) {
                successors.add(tgt);
            }
        }
    }

    // check if all the incoming are satisfied
    Collection<Step> removables = new HashSet<Step>();
    Collection<Step> incomings = new HashSet<Step>();
    for (Step successor : successors) {
        incomings.clear();
        for (Dependency in : successor.getIncomings()) {
            incomings.add(in.getSource());
        }
        for (Step incoming : incomings) {
            if (!(ancestors.contains(incoming) || incoming.getAttribute(firingAttributeId, false))) {
                removables.add(successor);
            }
        }
    }
    successors.removeAll(removables);

    // check if new nodes should be searched
    maxDegree--;
    maxNodes -= successors.size();
    if (!(successors.isEmpty() || maxDegree <= 0 || maxNodes <= 0)) {
        Set<Step> newAnchestors = Sets.union(ancestors, successors);
        successors.addAll(find(newAnchestors, maxNodes, maxDegree, firingAttributeId));
    }

    return successors;

}

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

public AbstractHierarchy(SortedMap<T, SortedSet<T>> hierarchyUp, SortedMap<T, SortedSet<T>> hierarchyDown) {
    this.hierarchyUp = hierarchyUp;
    this.hierarchyDown = hierarchyDown;

    // find most general and most special entities
    for (T entity : Sets.union(hierarchyUp.keySet(), hierarchyDown.keySet())) {
        SortedSet<T> moreGen = getParents(entity);
        SortedSet<T> moreSpec = getChildren(entity);

        if (moreGen.size() == 0 || (moreGen.size() == 1 && moreGen.first().isTopEntity()))
            rootEntities.add(entity);/*from w  ww  . j  a  va  2 s .c  o  m*/

        if (moreSpec.size() == 0 || (moreSpec.size() == 1 && moreSpec.first().isBottomEntity()))
            leafEntities.add(entity);
    }
}

From source file:org.mitre.openid.connect.client.service.impl.HybridIssuerService.java

public Set<String> getWhitelist() {
    return Sets.union(thirdPartyIssuerService.getWhitelist(), webfingerIssuerService.getWhitelist());
}

From source file:com.textocat.textokit.morph.ruscorpora.RusCorpora2OpenCorporaTagMapper.java

@Override
public void mapFromRusCorpora(RusCorporaWordform srcWf, Wordform targetWf) {
    JCas jCas;/*from w ww  .ja v  a  2 s  . c  o m*/
    try {
        jCas = targetWf.getCAS().getJCas();
    } catch (CASException e) {
        throw new RuntimeException(e);
    }
    if (srcWf.getLex() != null) {
        targetWf.setLemma(srcWf.getLex());
    }
    WordformBuilder wb = new WordformBuilder();
    // pos
    {
        Submapper posMapper = subMappers.get(srcWf.getPos());
        if (posMapper == null) {
            throw new IllegalStateException(String.format("Unhandled pos: %s", srcWf.getPos()));
        }
        posMapper.map(srcWf, wb);
    }
    //
    Set<String> srcGrams = Sets.union(srcWf.getLexGrammems(), srcWf.getWordformGrammems());
    for (String srcGr : srcGrams) {
        Submapper grMapper = subMappers.get(srcGr);
        if (grMapper == null) {
            throw new IllegalStateException(String.format("Unhandled tag: %s", srcGr));
        }
        grMapper.map(srcWf, wb);
    }
    // run post-processing submappers
    for (Submapper pp : postProcessors) {
        pp.map(srcWf, wb);
    }
    // set attributes in target FeatureStructure
    targetWf.setPos(wb.pos);
    // fill grammems array
    LinkedList<String> resultGrams = Lists.newLinkedList(wb.grammems);
    if (wb.pos != null) {
        resultGrams.addFirst(wb.pos);
    }
    targetWf.setGrammems(FSUtils.toStringArray(jCas, resultGrams));
}

From source file:google.registry.util.DiffUtils.java

/** Compare two maps and return a map containing, at each key where they differed, both values. */
public static ImmutableMap<?, ?> deepDiff(Map<?, ?> a, Map<?, ?> b, boolean ignoreNullToCollection) {
    ImmutableMap.Builder<Object, Object> diff = new ImmutableMap.Builder<>();
    for (Object key : Sets.union(a.keySet(), b.keySet())) {
        Object aValue = a.get(key);
        Object bValue = b.get(key);
        if (Objects.equals(aValue, bValue)) {
            // The objects are equal, so print nothing.
        } else if (ignoreNullToCollection && aValue == null && bValue instanceof Collection
                && ((Collection<?>) bValue).isEmpty()) {
            // Ignore a mismatch between Objectify's use of null to store empty collections and our
            // code's builder methods, which yield empty collections for the same fields.  This
            // prevents useless lines of the form "[null, []]" from appearing in diffs.
        } else {/*from  w ww  .j a va  2 s  . c  o  m*/
            // The objects aren't equal, so output a diff.
            if (aValue instanceof String && bValue instanceof String && a.toString().contains("\n")
                    && b.toString().contains("\n")) {
                aValue = stringToMap((String) aValue);
                bValue = stringToMap((String) bValue);
            } else if (aValue instanceof Set && bValue instanceof Set) {
                // Leave Sets alone; prettyPrintDiffedMap has special handling for Sets.
            } else if (aValue instanceof Iterable && bValue instanceof Iterable) {
                aValue = iterableToSortedMap((Iterable<?>) aValue);
                bValue = iterableToSortedMap((Iterable<?>) bValue);
            }
            diff.put(key,
                    (aValue instanceof Map && bValue instanceof Map)
                            ? deepDiff((Map<?, ?>) aValue, (Map<?, ?>) bValue, ignoreNullToCollection)
                            : new DiffPair(aValue, bValue));
        }
    }
    return diff.build();
}

From source file:org.apache.james.jmap.utils.KeywordsCombiner.java

@Override
public Keywords apply(Keywords keywords, Keywords keywords2) {
    return keywordsFactory
            .fromSet(Sets.union(union(keywords.getKeywords(), keywords2.getKeywords(), KEYWORD_NOT_TO_UNION),
                    intersect(keywords.getKeywords(), keywords2.getKeywords(), KEYWORD_TO_INTERSECT)));
}

From source file:es.usc.citius.composit.core.matcher.graph.HashMatchGraph.java

public HashMatchGraph(MatchTable<E, T> matchResult) {
    this.matchTable = matchResult;
    this.elements = Sets.union(matchResult.getMatchTable().columnKeySet(),
            matchResult.getMatchTable().rowKeySet());
}

From source file:org.jboss.hal.client.runtime.subsystem.jaxrs.RestResource.java

Set<String> getConsumes() {
    return Sets.union(mediaType(REST_RESOURCE_PATHS, CONSUMES), mediaType(SUB_RESOURCE_LOCATORS, CONSUMES))
            .immutableCopy();
}