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

public static <T> void removeWithoutUsingRemoveMethod(List<T> list, int index) {
    if (index < 0 || index >= list.size()) {
        throw new IllegalArgumentException("index out of range");
    }/*from   w w  w . j a v a 2  s .  c o m*/
    List<T> part1 = new ArrayList<T>(list.subList(0, index));
    List<T> part2 = new ArrayList<T>(list.subList(index + 1, list.size()));
    list.clear();
    list.addAll(part1);
    list.addAll(part2);
}

From source file:models.PushedBranch.java

public static List<PushedBranch> findByOwnerAndOriginalProject(User owner, Project originalProject) {
    List<PushedBranch> branches = new ArrayList<>();
    List<Project> forkedProjects = Project.findByOwnerAndOriginalProject(owner.loginId, originalProject);
    for (Project forkedProject : forkedProjects) {
        branches.addAll(forkedProject.getRecentlyPushedBranches());
    }/*  ww w.  j  av  a2  s.c o m*/
    return branches;
}

From source file:io.fabric8.forge.camel.commands.project.dto.NodeDtos.java

public static List<NodeDto> toNodeList(Iterable<? extends NodeDto> nodes, String indentation) {
    List<NodeDto> answer = new ArrayList<>();
    if (nodes != null) {
        for (NodeDto node : nodes) {
            List<NodeDto> list = node.toNodeList(indentation);
            answer.addAll(list);
        }//  ww  w. java  2 s  .c  om
    }
    return answer;
}

From source file:com.asakusafw.directio.hive.tools.cli.GenerateCreateTable.java

static GenerateCreateTableTask.Configuration parseConfiguration(String... args) throws ParseException {
    LOG.debug("Analyzing arguments: {}", Arrays.toString(args)); //$NON-NLS-1$

    CommandLineParser parser = new BasicParser();
    CommandLine cmd = parser.parse(OPTIONS, args);
    String classpath = getOption(cmd, OPT_CLASSPATH);
    String pluginpath = getOption(cmd, OPT_PLUGINPATH);
    String output = getOption(cmd, OPT_OUTPUT);
    String include = getOption(cmd, OPT_INCLUDE);
    String location = getOption(cmd, OPT_LOCATION);
    String database = getOption(cmd, OPT_DATABASE);

    List<File> sources = parseFileList(classpath);
    List<File> plugins = parseFileList(pluginpath);
    List<File> classpathAdditions = new ArrayList<>();
    classpathAdditions.addAll(sources);
    classpathAdditions.addAll(plugins);/*w  w w .j  a va2 s.c o m*/

    Pattern acceptTableNames = null;
    if (include != null) {
        try {
            acceptTableNames = Pattern.compile(include);
        } catch (PatternSyntaxException e) {
            throw new IllegalArgumentException(
                    MessageFormat.format(Messages.getString("GenerateCreateTable.errorInvalidInclude"), //$NON-NLS-1$
                            OPT_INCLUDE.getLongOpt(), include));
        }
    }

    Function<TableInfo, String> locationProvider = null;
    if (location != null) {
        String prefix = location.endsWith("/") ? location : location + '/'; //$NON-NLS-1$
        locationProvider = table -> prefix + table.getName();
    }

    if (database != null) {
        database = database.trim();
        if (database.isEmpty()) {
            database = null;
        }
    }
    File outputFile = new File(output);
    URLClassLoader classLoader = buildPluginLoader(GenerateCreateTable.class.getClassLoader(),
            classpathAdditions);
    return new GenerateCreateTableTask.Configuration(classLoader, sources, acceptTableNames, locationProvider,
            database, outputFile);
}

From source file:Main.java

public static <T> void addTailAndRemoveOldIfNeed(List<T> dest, List<T> src) {
    if (dest == null) {
        return;//w  w  w.j a v a  2s . c  om
    }

    if (src == null || src.isEmpty()) {
        return;
    }

    removeDuplicate(dest, src);
    if (dest.isEmpty()) {
        dest.addAll(src);
    } else {
        dest.addAll(dest.size(), src);
    }
}

From source file:de.cubeisland.engine.core.util.McUUID.java

private static int readProfilesFromInputStream(InputStream is, List<Profile> profiles) throws IOException {
    ProfileSearchResult results = mapper.readValue(is, ProfileSearchResult.class);
    profiles.addAll(Arrays.asList(results.profiles));
    return results.size;
}

From source file:Main.java

private static boolean isCandidate(Method m, String methodName, List<Object> availableParams,
        List<Object> paramsContainer) {
    if (m.getName().equals(methodName) == false) {
        return false;
    }/*ww  w  .j a  v a  2 s .  co m*/

    Class<?>[] paramTypes = m.getParameterTypes();
    if (paramTypes.length == 0) {
        return true;
    }

    paramsContainer.addAll(createParamsArray(m, availableParams));

    /*
     * we found match for every type
     */
    return paramsContainer.size() == paramTypes.length;
}

From source file:net.cpollet.jixture.hibernate3.helper.Hibernate3MappingDefinitionHolder.java

private static Iterable<Field> getFieldsUpToObject(Class<?> startClass) {
    List<Field> currentClassFields = new ArrayList<Field>();
    currentClassFields.addAll(Arrays.asList(startClass.getDeclaredFields()));
    Class<?> parentClass = startClass.getSuperclass();

    if (null != parentClass) {
        List<Field> parentClassFields = (List<Field>) getFieldsUpToObject(parentClass);
        currentClassFields.addAll(parentClassFields);
    }/* w ww.  ja  va2 s.  c o  m*/

    return currentClassFields;
}

From source file:com.bluexml.side.util.libs.ecore.EcoreHelper.java

public static List<Diagnostic> getAllDiag(Diagnostic diagnostics) {
    List<Diagnostic> l = new ArrayList<Diagnostic>();
    l.add(diagnostics);//from   w  ww.ja v a  2s.  c  o m
    List<Diagnostic> children = diagnostics.getChildren();
    for (Diagnostic diagnostic : children) {
        l.addAll(getAllDiag(diagnostic));
    }
    return l;
}

From source file:edu.cornell.mannlib.vitro.webapp.edit.n3editing.VTwo.N3EditUtils.java

/** Several places could give an editor URI. Return the first one. */
public static String getEditorUri(HttpServletRequest request) {
    IdentifierBundle ids = RequestIdentifiers.getIdBundleForRequest(request);

    List<String> uris = new ArrayList<String>();
    uris.addAll(IsUser.getUserUris(ids));
    uris.addAll(HasProfile.getProfileUris(ids));
    uris.add("Unknown N3 Editor");
    return uris.get(0);
}