Example usage for java.util Set addAll

List of usage examples for java.util Set addAll

Introduction

In this page you can find the example usage for java.util Set addAll.

Prototype

boolean addAll(Collection<? extends E> c);

Source Link

Document

Adds all of the elements in the specified collection to this set if they're not already present (optional operation).

Usage

From source file:com.vmware.admiral.compute.container.volume.VolumeUtil.java

private static List<Set<String>> mergeSets(List<Set<String>> list) {
    if (list.size() < 2) {
        return list;
    }//from   ww  w. ja  v  a 2s  .  c o  m

    for (int i = 0; i < list.size() - 1; i++) {
        Set<String> current = list.get(i);
        Set<String> next = list.get(i + 1);
        if (!disjoint(current, next)) {
            list.remove(current);
            list.remove(next);
            current.addAll(next);
            list.add(current);
            list = mergeSets(list);
            break;
        }
    }

    return list;
}

From source file:annis.CommonHelper.java

public static Set<String> getTokenAnnotationLevelSet(SaltProject p) {
    Set<String> result = new TreeSet<String>();

    for (SCorpusGraph corpusGraphs : p.getSCorpusGraphs()) {
        for (SDocument doc : corpusGraphs.getSDocuments()) {
            SDocumentGraph g = doc.getSDocumentGraph();
            result.addAll(getTokenAnnotationLevelSet(g));
        }//from   ww  w.j  ava  2  s.c  o m
    }

    return result;
}

From source file:com.espertech.esper.view.ViewServiceHelper.java

public static Set<String> getUniqueCandidateProperties(List<ViewFactory> viewFactory,
        Annotation[] annotations) {
    boolean disableUniqueImplicit = HintEnum.DISABLE_UNIQUE_IMPLICIT_IDX.getHint(annotations) != null;
    if (viewFactory == null || viewFactory.isEmpty()) {
        return null;
    }/*w ww.  ja v a  2  s .co m*/
    if (viewFactory.get(0) instanceof GroupByViewFactoryMarker) {
        ExprNode[] criteria = ((GroupByViewFactoryMarker) viewFactory.get(0)).getCriteriaExpressions();
        Set<String> groupedCriteria = ExprNodeUtility.getPropertyNamesIfAllProps(criteria);
        if (groupedCriteria == null) {
            return null;
        }
        if (viewFactory.get(1) instanceof DataWindowViewFactoryUniqueCandidate && !disableUniqueImplicit) {
            DataWindowViewFactoryUniqueCandidate uniqueFactory = (DataWindowViewFactoryUniqueCandidate) viewFactory
                    .get(1);
            Set<String> uniqueCandidates = uniqueFactory.getUniquenessCandidatePropertyNames();
            if (uniqueCandidates != null) {
                uniqueCandidates.addAll(groupedCriteria);
            }
            return uniqueCandidates;
        }
        return null;
    } else if (viewFactory.get(0) instanceof DataWindowViewFactoryUniqueCandidate && !disableUniqueImplicit) {
        DataWindowViewFactoryUniqueCandidate uniqueFactory = (DataWindowViewFactoryUniqueCandidate) viewFactory
                .get(0);
        return uniqueFactory.getUniquenessCandidatePropertyNames();
    } else if (viewFactory.get(0) instanceof VirtualDWViewFactory) {
        VirtualDWViewFactory vdw = (VirtualDWViewFactory) viewFactory.get(0);
        return vdw.getUniqueKeys();
    }
    return null;
}

From source file:org.jboss.aerogear.unifiedpush.utils.installation.InstallationUtils.java

private static Set<String> getRandomCategories(List<String> categories, int categoriesPerInstallation) {

    Set<String> picked = new HashSet<String>();

    Collections.shuffle(categories);

    picked.addAll(categories.subList(0, categoriesPerInstallation));

    return picked;
}

From source file:com.opengamma.web.WebAbout.java

private static Set<URL> forManifest(final Iterable<URL> urls) {
    Set<URL> result = Sets.newLinkedHashSet();
    for (URL url : urls) {
        result.addAll(forManifest(url));
    }//  w w w.  ja  v  a  2 s. c o m
    return result;
}

From source file:com.intuit.tank.common.ScriptUtil.java

public static Set<String> getUsedVariables(ScriptStep step) {
    Set<String> ret = new HashSet<String>();
    ret.addAll(extractVariablesFromRequestData(step.getData()));
    ret.addAll(extractVariablesFromRequestData(step.getQueryStrings()));
    ret.addAll(extractVariablesFromRequestData(step.getPostDatas()));
    ret.addAll(extractVariablesFromRequestData(step.getRequestheaders()));
    ret.addAll(extractVariablesFromRequestData(step.getRequestCookies()));
    extractVariables(ret, step.getPayload());
    extractVariables(ret, step.getHostname());
    extractVariables(ret, step.getSimplePath());
    return ret;//from www  . j  a  va2 s  .  c  om
}

From source file:edu.wpi.checksims.ChecksimsCommandLine.java

/**
 * Build the collection of submissions Checksims will be run on.
 *
 * TODO add unit tests//from  ww w  .j  ava2  s .  co  m
 *
 * @param cli Parsed command line options
 * @param glob Glob matcher to use when building submissions
 * @param tokenizer Tokenizer to use when building submissions
 * @param recursive Whether to recursively traverse when building submissions
 * @return Collection of submissions which will be used to run Checksims
 * @throws IOException Thrown on issue reading files or traversing directories to build submissions
 */
static Set<Submission> getSubmissions(CommandLine cli, String glob, Tokenizer tokenizer, boolean recursive)
        throws IOException, ChecksimsException {
    checkNotNull(cli);
    checkNotNull(glob);

    String[] unusedArgs = cli.getArgs();
    List<File> submissionDirs = new ArrayList<>();

    if (unusedArgs.length < 2) {
        throw new ChecksimsException("Expected at least 2 arguments: glob pattern and a submission directory!");
    }

    // The first element in args should be the glob matcher, so start at index 1
    for (int i = 1; i < unusedArgs.length; i++) {
        logs.debug("Adding directory " + unusedArgs[i]);
        submissionDirs.add(new File(unusedArgs[i]));
    }

    // Generate submissions to work on
    Set<Submission> submissions = new HashSet<>();
    for (File dir : submissionDirs) {
        submissions.addAll(Submission.submissionListFromDir(dir, glob, tokenizer, recursive));
    }

    if (submissions.isEmpty()) {
        throw new ChecksimsException("Did not obtain any submissions to operate on!");
    }

    return submissions;
}

From source file:com.hypersocket.i18n.I18N.java

public static Set<String> getResourceKeys(Locale locale, String resourceBundle) {
    if (resourceBundle == null) {
        throw new IllegalArgumentException("You must specify a resource bundle");
    }//from ww w. ja v a  2  s .  c  o  m

    String bundle = resourceBundle;
    if (!bundle.startsWith("i18n/")) {
        bundle = "i18n/" + resourceBundle;
    }

    Set<String> keys = new HashSet<String>();
    try {
        ResourceBundle rb = ResourceBundle.getBundle(bundle, locale, I18N.class.getClassLoader());
        keys.addAll(rb.keySet());
    } catch (MissingResourceException e) {

    }

    if (hasOverideBundle(locale, resourceBundle)) {
        try {
            ResourceBundle rb = new OverrideResourceBundle(locale, resourceBundle);
            keys.addAll(rb.keySet());
        } catch (IOException e1) {
            log.error("Failed to load override file for bundle " + resourceBundle);
        }
    }

    return keys;
}

From source file:org.openmrs.module.pagecheck.Pages.java

/**
 * Gets all URLs which have been mapped to controllers in Spring
 * @return the URLs/*w ww  . j  a  v  a  2s. c o m*/
 */
@SuppressWarnings("unchecked")
public static Set<String> getMappedURLs() {
    Set<String> urls = new TreeSet<String>();

    Map<String, SimpleUrlHandlerMapping> simpleHandlers = ContextProvider.getApplicationContext()
            .getBeansOfType(SimpleUrlHandlerMapping.class);
    Map<String, DefaultAnnotationHandlerMapping> annotationBeans = ContextProvider.getApplicationContext()
            .getBeansOfType(DefaultAnnotationHandlerMapping.class);

    for (SimpleUrlHandlerMapping handler : simpleHandlers.values())
        urls.addAll(handler.getHandlerMap().keySet());

    for (DefaultAnnotationHandlerMapping handler : annotationBeans.values())
        urls.addAll(handler.getHandlerMap().keySet());

    return urls;
}

From source file:biz.netcentric.cq.tools.actool.helper.AccessControlUtils.java

/** Converts the given privilege names into a set of privilege objects.
 * /*from   w w w  .  j ava2s  .c  o m*/
 * @param privNames (may be {@code null}
 * @param acMgr
 * @return a set of privileges (never {@code null}, but may be empty set)
 * @throws RepositoryException */
public static Set<Privilege> getPrivilegeSet(String[] privNames, AccessControlManager acMgr)
        throws RepositoryException {
    if (privNames == null) {
        return Collections.emptySet();
    }
    final Set privileges = new HashSet(privNames.length);
    for (final String name : privNames) {
        final Privilege p = acMgr.privilegeFromName(name);
        if (p.isAggregate()) {
            privileges.addAll(Arrays.asList(p.getAggregatePrivileges()));
        } else {
            privileges.add(p);
        }
    }
    return privileges;
}