Example usage for java.util List addAll

List of usage examples for java.util List addAll

Introduction

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

Prototype

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

Source Link

Document

Appends all of the elements in the specified collection to the end of this list, in the order that they are returned by the specified collection's iterator (optional operation).

Usage

From source file:Main.java

/**
 * Copy fields from parent object to child object.
 *
 * @param parent parent object/*from   ww w. j  av  a 2  s  .c  o m*/
 * @param child child object
 * @param <T> child class
 * @return filled child object
 */
public static <T> T shallowCopy(Object parent, T child) {
    try {
        List<Field> fields = new ArrayList<>();
        Class clazz = parent.getClass();
        do {
            fields.addAll(Arrays.asList(clazz.getDeclaredFields()));
        } while (!(clazz = clazz.getSuperclass()).equals(Object.class));

        for (Field field : fields) {
            field.setAccessible(true);
            field.set(child, field.get(parent));
        }

        return child;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:Main.java

public static List<Integer> diff(List<Integer> l1, List<Integer> l2) {
    List<Integer> aux1 = new ArrayList<Integer>(l1);
    List<Integer> aux2 = new ArrayList<Integer>(l2);
    aux1.removeAll(l2);//from   ww w .j a  va2s . c  om
    aux2.removeAll(l1);
    aux1.addAll(aux2);
    return aux1;
}

From source file:com.amalto.workbench.detailtabs.sections.model.annotationinfo.relationship.ForeignKeyFilterAnnoInfo.java

public static ForeignKeyFilterAnnoInfoDefUnit[] getFKFilterCfgInfos(String filterExpression) {

    if ("".equals(filterExpression) || isCustomFilter(filterExpression))//$NON-NLS-1$
        return new ForeignKeyFilterAnnoInfoDefUnit[0];

    List<ForeignKeyFilterAnnoInfoDefUnit> fkFilterInfos = new ArrayList<ForeignKeyFilterAnnoInfoDefUnit>();

    if (filterExpression != null) {
        String[] criterias = filterExpression.split("#");//$NON-NLS-1$
        for (String cria : criterias) {
            String[] values = cria.split("\\$\\$");//$NON-NLS-1$
            List<String> list = new ArrayList<String>();
            list.addAll(Arrays.asList(values));
            int num = 4 - list.size();
            for (int i = 0; i < num; i++) {
                list.add("");//$NON-NLS-1$
            }//from w ww.j  ava 2  s  .  co  m

            fkFilterInfos.add(new ForeignKeyFilterAnnoInfoDefUnit(list.get(0), list.get(1),
                    list.get(2).replaceAll("&quot;", //$NON-NLS-1$
                            "\""), //$NON-NLS-1$
                    list.get(3)));

        }
    }
    return fkFilterInfos.toArray(new ForeignKeyFilterAnnoInfoDefUnit[0]);

}

From source file:Main.java

public static <E> Collection<List<E>> selectUpTo(List<E> original, int nb) {
    final List<List<E>> result = new ArrayList<List<E>>();
    for (int i = 1; i <= nb; i++) {
        result.addAll(selectExactly(original, i));
    }/*w  w  w.java  2  s  .  c  o  m*/
    return Collections.unmodifiableList(result);
}

From source file:com.evolveum.midpoint.util.logging.LoggingUtils.java

private static void logExceptionInternal(Level first, Level second, Trace LOGGER, String message, Throwable ex,
        Object... objects) {// w w  w  .j a v a 2 s .c o  m
    Validate.notNull(LOGGER, "Logger can't be null.");
    Validate.notNull(ex, "Exception can't be null.");

    List<Object> args = new ArrayList<>();
    args.addAll(Arrays.asList(objects));
    args.add(ex.getMessage() + " (" + ex.getClass() + ")");

    if (!first.equals(second)) {
        log(LOGGER, first, message + ", reason: {}", args.toArray());
    }
    // Add exception to the list. It will be the last argument without {} in the message,
    // therefore the stack trace will get logged
    args.add(ex);
    log(LOGGER, second, message + ".", args.toArray());
}

From source file:com.thoughtworks.go.agent.common.util.JarUtil.java

public static URLClassLoader getClassLoaderFromJar(File aJarFile, Predicate<JarEntry> extractFilter,
        File outputTmpDir, ClassLoader parentClassLoader, Class... allowedClasses) {
    List<File> urls = new ArrayList<>();
    urls.add(aJarFile);/*from   w  w  w . j a v a  2  s . com*/
    urls.addAll(extractFilesInLibDirAndReturnFiles(aJarFile, extractFilter, outputTmpDir));
    ParentClassAccessFilteringClassloader filteringClassloader = new ParentClassAccessFilteringClassloader(
            parentClassLoader, allowedClasses);
    return new URLClassLoader(toURLs(urls), filteringClassloader);
}

From source file:de.tsystems.mms.apm.performancesignature.ui.PerfSigUIPlugin.java

@Initializer(after = JOB_LOADED)
public static void init1() throws IOException, InterruptedException {
    // Check for old dashboard configurations
    for (Job<?, ?> job : PerfSigUIUtils.getInstance().getAllItems(Job.class)) {
        FilePath jobPath = new FilePath(job.getConfigFile().getFile()).getParent();
        if (jobPath == null) {
            continue;
        }//from   w ww.java 2  s  .co  m
        List<FilePath> files = jobPath.list(new RegexFileFilter(".*-config.json"));
        files.addAll(jobPath.list(new RegexFileFilter("gridconfig.*.json")));
        for (FilePath file : files) {
            file.delete();
        }
    }
}

From source file:Main.java

/**
 * Internal function to realize the mathematical combination of given
 * values. This method creates the next sub-tree by iterating over values
 * given by parameter set./*  www.  j  a  v  a2  s.  co  m*/
 * 
 * @param <E>
 *            the type of the given and returned values
 * @param list
 *            the possible values for next iteration
 * @param combination
 *            the current path of the abstract combination tree
 * @param combinations
 *            overall combinations
 */
private static <E extends Object> void combination(List<E> list, List<E> combination,
        List<List<E>> combinations) {
    for (E value : list) {
        List<E> combination_ = new LinkedList<E>();
        combination_.addAll(combination);
        combination_.add(value);
        combinations.add(combination_);

        List<E> list_ = new LinkedList<E>();
        list_.addAll(list);
        list_.remove(list);
        if (!list_.isEmpty()) {
            combination(list_, combination_, combinations);
        }
    }
}

From source file:org.glassfish.jersey.osgi.test.basic.ApacheOsgiIntegrationTest.java

@Configuration
public static Option[] configuration() {
    final List<Option> options = Helper.getCommonOsgiOptions();
    options.addAll(Helper.expandedList(
            mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").versionAsInProject(),
            mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpcore-osgi").versionAsInProject(),
            mavenBundle().groupId("org.apache.httpcomponents").artifactId("httpclient-osgi")
                    .versionAsInProject(),
            mavenBundle().groupId("org.glassfish.jersey.connectors").artifactId("jersey-apache-connector")
                    .versionAsInProject()

    ));//from  w w w  .j  a va2  s . c om
    return Helper.asArray(options);
}

From source file:domainregistry.AdvancedSearch.java

private static List<String> getQueryParams(Map<String, String> parameters) {
    String res = parameters.get(RESOURCES);
    String schemes = parameters.get(SCHEMES);

    String[] resourceTypes = (res != null) ? res.split(",") : new String[0];
    String[] dataSchemes = (schemes != null) ? schemes.split(",") : new String[0];

    List<String> prefixResourceType = map(Arrays.asList(resourceTypes), RESOURCES_PREFIX);
    List<String> prefixSchemeType = map(Arrays.asList(dataSchemes), SCHEMES_PREFIX);

    List<String> hypertyPrefixParams = new ArrayList<String>(prefixResourceType);
    hypertyPrefixParams.addAll(prefixSchemeType);

    return hypertyPrefixParams;
}