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:springfox.documentation.swagger.readers.operation.SwaggerOperationTagsReader.java

private Function<Api, Set<String>> tagsFromController() {
    return new Function<Api, Set<String>>() {
        @Override//from w w  w .j av a 2  s.  c om
        public Set<String> apply(Api input) {
            Set<String> tags = newTreeSet();
            tags.addAll(from(newArrayList(input.tags())).filter(emptyTags()).toSet());
            return tags;
        }
    };
}

From source file:it.units.malelab.ege.util.Utils.java

public static <T> Node<T> expand(T symbol, Grammar<T> grammar, int depth, int maxDepth) {
    //TODO something not good here on text.bnf
    if (depth > maxDepth) {
        return null;
    }/*from   w  ww .j  a v a  2s . c  om*/
    Node<T> node = new Node<>(symbol);
    List<List<T>> options = grammar.getRules().get(symbol);
    if (options == null) {
        return node;
    }
    Set<Node<T>> children = new LinkedHashSet<>();
    for (List<T> option : options) {
        Set<Node<T>> optionChildren = new LinkedHashSet<>();
        boolean nullNode = false;
        for (T optionSymbol : option) {
            Node<T> child = expand(optionSymbol, grammar, depth + 1, maxDepth);
            if (child == null) {
                nullNode = true;
                break;
            }
            optionChildren.add(child);
        }
        if (!nullNode) {
            children.addAll(optionChildren);
        }
    }
    if (children.isEmpty()) {
        return null;
    }
    for (Node<T> child : children) {
        node.getChildren().add(child);
    }
    node.propagateParentship();
    return node;
}

From source file:fi.hsl.parkandride.ActiveProfileAppender.java

private Set<String> currentActiveProfiles() {
    String springProfilesActive = System.getProperty("spring.profiles.active");
    if (isNullOrEmpty(springProfilesActive)) {
        springProfilesActive = System.getenv("SPRING_PROFILES_ACTIVE");
    }//from   w ww  . j  a v  a  2s. c  o  m

    Set<String> profiles = new LinkedHashSet<>();
    if (!isNullOrEmpty(springProfilesActive)) {
        profiles.addAll(asList(springProfilesActive.split(",")));
    }
    return profiles;
}

From source file:com.hmsinc.epicenter.classifier.SimpleMapClassifier.java

public Collection<String> getCategories() {
    final Set<String> categories = new HashSet<String>();
    categories.addAll(classifier.values());
    return categories;
}

From source file:de.inren.service.group.GroupServiceImpl.java

@Override
public void init() {
    if (!initDone) {
        log.info("GroupService init start.");
        roleService.init();/* w ww .ja  v  a2  s  .c  o  m*/
        List<Group> groups = (List<Group>) groupRepository.findAll();
        if (groups.isEmpty()) {
            final Group all = new Group("all", "All roles");
            Set<Role> groupRoles = new HashSet<Role>();
            groupRoles.addAll(roleService.loadAllRoles());
            all.setRoles(groupRoles);
            groupRepository.save(all);
        }
        initDone = true;
        log.info("GroupService init done.");
    }
}

From source file:no.dusken.common.plugin.security.PluginAuthenticationProviderManager.java

public void pluginManagerStarted() {
    if (++providerManagersStarted == pluginManagers.size()) {
        Set providers = new HashSet();
        try {/*from  w  w w  .ja va2 s.  c  om*/
            providers.addAll(authenticationManager.getProviders());
        } catch (IllegalArgumentException iae) {
            // No providers!
        }
        for (PluginManager<DuskenPlugin> pm : pluginManagers) {
            for (DuskenPlugin plugin : pm.getPlugins()) {
                AuthenticationProvider provider = plugin.getAuthenticationProvider();
                if (provider != null) {
                    providers.add(provider);
                }
            }
        }
        authenticationManager.setProviders(new LinkedList(providers));
    }
}

From source file:gov.nih.nci.ncicb.tcga.dcc.qclive.common.action.DroppedBarcodeFinder.java

private Collection<BCRID> filterBarcodes(final Collection<BCRID> currentBarcodeList,
        final Collection<BCRID> previousBarcodeList) {
    // put them into a Set to make sure there are no duplicates
    final Set<BCRID> currentBarcodeSet = new HashSet<BCRID>();
    currentBarcodeSet.addAll(currentBarcodeList);
    final Set<BCRID> previousBarcodeSet = new HashSet<BCRID>();
    previousBarcodeSet.addAll(previousBarcodeList);
    final Collection<BCRID> droppedBarcodes = CollectionUtils.subtract(previousBarcodeSet, currentBarcodeSet);
    if (droppedBarcodes.size() != 0) {
        for (Iterator<BCRID> it = droppedBarcodes.iterator(); it.hasNext();) {
            if (it.next().getViewable() != 1) {
                it.remove();//  w w  w  .  ja v a 2 s.  c  o  m
            }
        }
    }
    return droppedBarcodes;
}

From source file:org.alfresco.mobile.android.api.services.impl.AbstractDocumentFolderServiceImpl.java

private static String addAspects(String objectId, List<String> nodeAspects, List<String> aspectToApplied) {
    String objectIdWithAspects = objectId;

    Set<String> aspects = new HashSet<String>(nodeAspects);
    if (aspectToApplied != null) {
        aspects.addAll(aspectToApplied);
    }/* w w w  .  j a  v  a2 s  . c o m*/

    for (String aspect : aspects) {
        if (!objectIdWithAspects.contains(aspect)) {
            objectIdWithAspects = objectIdWithAspects.concat("," + CMISPREFIX_ASPECTS + aspect);
        }
    }

    return objectIdWithAspects;
}

From source file:com.textocat.textokit.commons.util.TrainDevTestCorpusSplitter.java

private void run() throws Exception {
    IOFileFilter corpusFileFilter;/*w w  w .  jav a2s  . co  m*/
    if (corpusFileSuffix == null) {
        corpusFileFilter = FileFilterUtils.trueFileFilter();
    } else {
        corpusFileFilter = FileFilterUtils.suffixFileFilter(corpusFileSuffix);
    }
    IOFileFilter corpusSubDirFilter = includeSubDirectores ? TrueFileFilter.INSTANCE : null;
    List<Set<File>> partitions = Lists.newArrayList(CorpusUtils.partitionCorpusByFileSize(corpusDir,
            corpusFileFilter, corpusSubDirFilter, partitionsNum));
    if (partitions.size() != partitionsNum) {
        throw new IllegalStateException();
    }
    // make dev partition from the last because it is a little bit smaller
    Set<File> devFiles = getAndRemove(partitions, partitions.size() - 1);
    Set<File> testFiles = getAndRemove(partitions, partitions.size() - 1);
    Set<File> trainFiles = Sets.newLinkedHashSet();
    for (Set<File> s : partitions) {
        trainFiles.addAll(s);
    }
    // write files
    File devPartFile = new File(outputDir, CorpusUtils.getDevPartitionFilename(0));
    FileUtils.writeLines(devPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, devFiles));
    File testPartFile = new File(outputDir, CorpusUtils.getTestPartitionFilename(0));
    FileUtils.writeLines(testPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, testFiles));
    File trainPartFile = new File(outputDir, CorpusUtils.getTrainPartitionFilename(0));
    FileUtils.writeLines(trainPartFile, "utf-8", CorpusUtils.toRelativePaths(corpusDir, trainFiles));
}

From source file:dk.statsbiblioteket.doms.licensemodule.validation.LicenseValidator.java

public static CheckAccessForIdsOutputDTO checkAccessForIds(CheckAccessForIdsInputDTO input) throws Exception {

    if (input.getIds() == null || input.getIds().size() == 0) {
        throw new IllegalArgumentException("No ID's in input");
    }// w w w. j a  va  2 s.  c o m

    //Get the query. This also validates the input 
    GetUserQueryInputDTO inputQuery = new GetUserQueryInputDTO();
    inputQuery.setAttributes(input.getAttributes());
    inputQuery.setPresentationType(input.getPresentationType());
    GetUserQueryOutputDTO query = getUserQuery(inputQuery);

    CheckAccessForIdsOutputDTO output = new CheckAccessForIdsOutputDTO();
    output.setPresentationType(input.getPresentationType());
    output.setQuery(query.getQuery());

    ArrayList<SolrServerClient> servers = LicenseModulePropertiesLoader.SOLR_SERVERS;

    // merge (union) results.   
    Set<String> filteredIdsSet = new HashSet<String>();

    //Next step: use Future's to make multithreaded when we get more servers. 
    //But currently these requests are less 10 ms
    for (SolrServerClient server : servers) {
        ArrayList<String> filteredIds = server.filterIds(input.getIds(), query.getQuery());
        log.info("#filtered id for server (" + input.getPresentationType() + ") "
                + server.getSolrServer().getBaseURL() + " : " + filteredIds.size());
        filteredIdsSet.addAll(filteredIds);
    }
    //Now we have to remove remove ID's not asked for that are here because of multivalue field. (set intersection)
    filteredIdsSet.retainAll(input.getIds());

    output.setAccessIds(new ArrayList<String>(filteredIdsSet));
    //Sanity check!
    if (output.getAccessIds().size() > input.getIds().size()) {
        throw new IllegalArgumentException(
                "Security problem: More Id's in output than input. Check for query injection.");
    }

    log.debug(
            "#query IDs=" + input.getIds().size() + " returned #filtered IDs=" + output.getAccessIds().size());
    return output;
}