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.linecorp.armeria.server.docs.Specification.java

static Specification forServiceClasses(Map<Class<?>, Iterable<EndpointInfo>> map,
        Map<Class<?>, ? extends TBase<?, ?>> sampleRequests) {
    requireNonNull(map, "map");

    final List<ServiceInfo> services = new ArrayList<>(map.size());
    final Set<ClassInfo> classes = new HashSet<>();
    map.forEach((serviceClass, endpoints) -> {
        try {//from   www . j a  v a2 s . com
            final ServiceInfo service = ServiceInfo.of(serviceClass, endpoints, sampleRequests);
            services.add(service);
            classes.addAll(service.classes().values());
        } catch (ClassNotFoundException e) {
            throw new RuntimeException("unable to initialize Specification", e);
        }
    });

    return new Specification(services, classes);
}

From source file:com.github.qwazer.markdown.confluence.gradle.plugin.ConfluenceGradleTask.java

protected static void validateNoDuplicates(Collection<ConfluenceConfig.Page> pages) {

    Set<ConfluenceConfig.Page> set = new TreeSet<>(new Comparator<ConfluenceConfig.Page>() {
        @Override//from  ww  w.j  a  va  2  s  . c om
        public int compare(ConfluenceConfig.Page o1, ConfluenceConfig.Page o2) {
            return o1.getTitle().compareTo(o2.getTitle());
        }
    });

    set.addAll(pages);

    if (set.size() < pages.size()) {
        throw new IllegalArgumentException("Found duplicate pageTitle in confluence pages");
    }
}

From source file:com.haulmont.cuba.gui.components.filter.UserSetHelper.java

public static String createIdsString(Set<String> current, Collection entities) {
    Set<String> convertedSet = new HashSet<>();
    for (Object entity : entities) {
        convertedSet.add(((BaseUuidEntity) entity).getId().toString());
    }//from  www . j  a  v  a  2 s .c om
    current.addAll(convertedSet);
    if (current.isEmpty()) {
        return "NULL";
    }
    StringBuilder listOfId = new StringBuilder();
    Iterator it = current.iterator();
    while (it.hasNext()) {
        listOfId.append(it.next());
        if (it.hasNext()) {
            listOfId.append(',');
        }
    }
    return listOfId.toString();
}

From source file:com.ocs.dynamo.domain.model.util.EntityModelUtil.java

/**
 * Copies all simple attribute values from one entity to the other
 * //from ww w  .  j  a va  2s  . co  m
 * @param source
 *            the source entity
 * @param target
 *            the target entity
 * @param model
 */
public static <T> void copySimpleAttributes(T source, T target, EntityModel<T> model, String... ignore) {
    Set<String> toIgnore = new HashSet<>();
    if (ignore != null) {
        toIgnore = Sets.newHashSet(ignore);
    }
    toIgnore.addAll(ALWAYS_IGNORE);

    for (AttributeModel am : model.getAttributeModels()) {
        if ((AttributeType.BASIC.equals(am.getAttributeType())
                || AttributeType.LOB.equals(am.getAttributeType())) && !toIgnore.contains(am.getName())) {
            if (!DynamoConstants.ID.equals(am.getName())) {
                Object value = ClassUtils.getFieldValue(source, am.getName());
                if (ClassUtils.canSetProperty(target, am.getName())) {
                    if (value != null) {
                        ClassUtils.setFieldValue(target, am.getName(), value);
                    } else {
                        ClassUtils.clearFieldValue(target, am.getName(), am.getType());
                    }
                }

            }
        }
    }
}

From source file:net.sourceforge.jaulp.io.annotations.ImportResourcesUtils.java

/**
 * Gets a map with ImportResource objects and the corresponding to the found class from the
 * given package Name. The search is made recursive. The key from an entry of the map is the
 * class where the ImportResource objects found and the value is an Array of the ImportResource
 * objects that contains in the class.//w  ww.  java2s .  c o m
 * 
 * @param packageName
 *            the package name
 * @return the import resources
 * @throws ClassNotFoundException
 *             the class not found exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static Map<Class<?>, ImportResource[]> getImportResources(String packageName)
        throws ClassNotFoundException, IOException {
    final Map<Class<?>, ImportResource[]> resourcesMap = new LinkedHashMap<>();

    final Class<ImportResources> importResourcesClass = ImportResources.class;
    final Class<ImportResource> importResourceClass = ImportResource.class;
    final Set<Class<?>> importResourcesClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourcesClass);
    final Set<Class<?>> importResourceClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourceClass);
    importResourcesClasses.addAll(importResourceClasses);
    for (Class<?> annotatedClass : importResourcesClasses) {
        final ImportResources importResources = annotatedClass.getAnnotation(ImportResources.class);
        ImportResource[] importResourcesArray = null;
        ImportResource[] importResourceArray = null;
        if (importResources != null) {
            importResourcesArray = importResources.resources();
        }

        final ImportResource importResource = annotatedClass.getAnnotation(ImportResource.class);
        if (importResource != null) {
            importResourceArray = new ImportResource[1];
            importResourceArray[0] = importResource;
        }
        ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray,
                importResourcesArray);
        Arrays.sort(array, new ImportResourceComparator());
        resourcesMap.put(annotatedClass, array);

    }
    return resourcesMap;
}

From source file:de.alpharogroup.io.annotations.ImportResourcesUtils.java

/**
 * Gets a map with ImportResource objects and the corresponding to the found class from the
 * given package Name. The search is made recursive. The key from an entry of the map is the
 * class where the ImportResource objects found and the value is an Array of the ImportResource
 * objects that contains in the class./*www  .j a  v a  2 s  .  c o m*/
 * 
 * @param packageName
 *            the package name
 * @return the import resources
 * @throws ClassNotFoundException
 *             the class not found exception
 * @throws IOException
 *             Signals that an I/O exception has occurred.
 */
public static Map<Class<?>, ImportResource[]> getImportResources(final String packageName)
        throws ClassNotFoundException, IOException {
    final Map<Class<?>, ImportResource[]> resourcesMap = new LinkedHashMap<>();

    final Class<ImportResources> importResourcesClass = ImportResources.class;
    final Class<ImportResource> importResourceClass = ImportResource.class;
    final Set<Class<?>> importResourcesClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourcesClass);
    final Set<Class<?>> importResourceClasses = AnnotationUtils.getAllAnnotatedClasses(packageName,
            importResourceClass);
    importResourcesClasses.addAll(importResourceClasses);
    for (final Class<?> annotatedClass : importResourcesClasses) {
        final ImportResources importResources = annotatedClass.getAnnotation(ImportResources.class);
        ImportResource[] importResourcesArray = null;
        ImportResource[] importResourceArray = null;
        if (importResources != null) {
            importResourcesArray = importResources.resources();
        }

        final ImportResource importResource = annotatedClass.getAnnotation(ImportResource.class);
        if (importResource != null) {
            importResourceArray = new ImportResource[1];
            importResourceArray[0] = importResource;
        }
        final ImportResource[] array = (ImportResource[]) ArrayUtils.addAll(importResourceArray,
                importResourcesArray);
        Arrays.sort(array, new ImportResourceComparator());
        resourcesMap.put(annotatedClass, array);

    }
    return resourcesMap;
}

From source file:io.cloudslang.maven.compiler.CloudSlangMavenCompiler.java

protected static String[] getSourceFiles(CompilerConfiguration config) {
    Set<String> sources = new HashSet<>();

    for (String sourceLocation : config.getSourceLocations()) {
        sources.addAll(getSourceFilesForSourceRoot(config, sourceLocation));
    }/*from w  w  w  .  j  a  v a  2s .  c o m*/

    return sources.toArray(new String[sources.size()]);
}

From source file:io.lavagna.web.helper.PermissionMethodInterceptor.java

private static Set<String> extractProjectIdsFromRequestUri(String requestUri, ProjectService projectService) {
    Set<String> projectIds = new HashSet<>();
    for (AbstractPermissionUrlPath p : URL_PATTERNS_TO_CHECK) {
        Set<String> extracted = p.tryToFetchProjectShortNames(requestUri, projectService);
        projectIds.addAll(extracted);
    }//from   ww  w  . ja v a2  s. com
    return projectIds;
}

From source file:com.ery.estorm.util.ServerCommandLine.java

/**
 * Logs information about the currently running JVM process including the environment variables. Logging of env vars can be disabled by
 * setting {@code "hbase.envvars.logging.disabled"} to {@code "true"}.
 * <p>/* w ww. j  av a2  s .  c o  m*/
 * If enabled, you can also exclude environment variables containing certain substrings by setting
 * {@code "hbase.envvars.logging.skipwords"} to comma separated list of such substrings.
 */
public static void logProcessInfo(Configuration conf) {
    // log environment variables unless asked not to
    if (conf == null || !conf.getBoolean("estorm.envvars.logging.disabled", false)) {
        Set<String> skipWords = new HashSet<String>(DEFAULT_SKIP_WORDS);
        if (conf != null) {
            String[] confSkipWords = conf.getStrings("hbase.envvars.logging.skipwords");
            if (confSkipWords != null) {
                skipWords.addAll(Arrays.asList(confSkipWords));
            }
        }

        nextEnv: for (Entry<String, String> entry : System.getenv().entrySet()) {
            String key = entry.getKey().toLowerCase();
            String value = entry.getValue().toLowerCase();
            // exclude variables which may contain skip words
            for (String skipWord : skipWords) {
                if (key.contains(skipWord) || value.contains(skipWord))
                    continue nextEnv;
            }
            LOG.info("env:" + entry);
        }
    }
    // and JVM info
    logJVMInfo();
}

From source file:Main.java

private static Set<File> getExpectationFiles(String dir) {
    Set<File> expectSet = new HashSet<File>();
    File[] files = new File(dir).listFiles(new FilenameFilter() {
        // ignore obviously temporary files
        public boolean accept(File dir, String name) {
            return !name.endsWith("~") && !name.startsWith(".");
        }/*from   w  w w  . j av  a 2s.co m*/
    });
    if (files != null) {
        expectSet.addAll(Arrays.asList(files));
    }
    return expectSet;
}