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:io.gravitee.maven.plugins.json.schema.generator.util.ClassFinder.java

/**
 * Find class names from the given root Path that matching the given list of globs.
 * <p/>/*from w w  w .j  a va2s. co  m*/
 * Class names are built following the given rule:
 * - Given the root Path: /root/path/
 * - Given the Class Path: /root/path/the/path/to/the/class/Class.class
 * - Then associated Class name would be: the.path.to.the.class.Class
 *
 * @param root  the root Path from which start searching
 * @param globs the glob list to taking into account during path matching
 * @return a list of Paths that match the given list of globs from the root Path
 * @throws IOException if an I/O occurs
 */
public static List<String> findClassNames(Path root, Globs globs) throws IOException {
    Validate.notNull(root, "Unable to handle null root path");
    Validate.isTrue(root.toFile().isDirectory(), "Unable to handle non existing or non directory root path");
    Validate.notNull(globs, "Unable to handle null globs");

    List<String> matchedClassNames = new ArrayList<>();
    matchedClassNames.addAll(findClassPaths(root, globs).stream()
            .map(path -> ClassUtils.convertClassPathToClassName(path.toString(), root.normalize().toString()))
            .collect(Collectors.toList()));
    return matchedClassNames;
}

From source file:com.jlfex.hermes.common.utils.CollectionUtil.java

/**
 * Set?  List?/*from www .j a  v  a  2 s .com*/
 * @param a
 * @return
 */
public static <T> List<T> switchSet2List(Set<T> a) {
    List<T> list = new ArrayList<T>();
    list.addAll(a);
    return list;
}

From source file:com.nextep.datadesigner.gui.service.GUIService.java

public static List<IEditorReference> getDependentEditors(Object o) {
    // We retrieve all editors pointing to a reference of a removed element to close them
    final List<IEditorReference> editorsToClose = new ArrayList<IEditorReference>();
    final List<Object> elts = new ArrayList<Object>();
    if (o instanceof IReferenceContainer) {
        elts.addAll(((IReferenceContainer) o).getReferenceMap().values());
    }/*from   www  .  jav  a  2s . c  o m*/
    elts.add(o);
    for (Object elt : elts) {
        if (elt instanceof ITypedObject) {
            ITypedObject model = (ITypedObject) elt;
            if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
                    && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null
                    && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                            .getEditorReferences() != null) {
                for (IEditorReference r : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
                        .getEditorReferences()) {
                    if (!editorsToClose.contains(r)) {
                        try {
                            IEditorInput input = r.getEditorInput();
                            if (input instanceof IModelOriented<?>) {
                                Object obj = ((IModelOriented<?>) input).getModel();
                                if (obj == model) {
                                    editorsToClose.add(r);
                                }
                            }
                        } catch (PartInitException e) {
                            log.warn("Unable to read editor state.");
                        }
                    }
                }
            }
        }
    }
    return editorsToClose;
}

From source file:pl.maciejwalkowiak.plist.FieldSerializer.java

private static List<Field> getAllFields(Class<?> type) {
    List<Field> fields = new ArrayList<Field>();
    for (Class<?> c = type; c != null; c = c.getSuperclass()) {
        fields.addAll(Arrays.asList(c.getDeclaredFields()));
    }//from www .  j  av  a 2  s.c  o  m
    return fields;
}

From source file:com.act.lcms.db.analysis.BestMoleculesPickerFromLCMSIonAnalysis.java

/**
 * This function is used to print the model either as a json or as a TSV file containing relevant statistics.
 * @param fileName The name of file/*from  w  w w . jav a 2 s.co m*/
 * @param jsonFormat Whether it needs to be outputted in a json format or a a list of inchis, one per line.
 * @param model The model that is being written
 * @throws IOException
 */
public static void printInchisAndIonsToFile(IonAnalysisInterchangeModel model, String fileName,
        Boolean jsonFormat) throws IOException {
    if (jsonFormat) {
        model.writeToJsonFile(new File(fileName));
    } else {
        List<String> header = new ArrayList<>();
        header.addAll(OUTPUT_TSV_HEADER_FIELDS);

        TSVWriter<String, String> writer = new TSVWriter<>(header);
        writer.open(new File(fileName));

        for (IonAnalysisInterchangeModel.ResultForMZ resultForMZ : model.getResults()) {
            for (IonAnalysisInterchangeModel.HitOrMiss molecule : resultForMZ.getMolecules()) {
                Map<String, String> row = new HashMap<>();
                row.put(HEADER_INCHI, molecule.getInchi());
                row.put(HEADER_ION, molecule.getIon());
                row.put(HEADER_MASS, MassCalculator.calculateMass(molecule.getInchi()).toString());
                row.put(HEADER_MZ, resultForMZ.getMz().toString());
                writer.append(row);
                writer.flush();
            }
        }

        writer.close();
    }
}

From source file:de.tynne.benchmarksuite.Main.java

/** Returns a producer for all benchmarks in the named suites.
 *//*from w  ww . j a v  a 2 s  .  c  om*/
private static BenchmarkProducer findAllByName(List<String> suiteNames,
        Map<BenchmarkSuite, BenchmarkProducer> suites) {
    List<BenchmarkProducer> benchmarkProducers = suiteNames.stream().map(s -> findByName(s, suites))
            .filter(bp -> bp.isPresent()).map(o -> o.get()).collect(Collectors.toList());

    return () -> {
        List<Benchmark> result = new ArrayList<>();
        benchmarkProducers.forEach(bp -> {
            result.addAll(bp.get());
        });
        return result;
    };
}

From source file:gobblin.util.FileListUtils.java

public static List<FileStatus> listFilesRecursively(FileSystem fs, Iterable<Path> paths) throws IOException {
    List<FileStatus> results = Lists.newArrayList();
    for (Path path : paths) {
        results.addAll(listFilesRecursively(fs, path));
    }/*from ww w.  j av a2  s .  c  o m*/
    return results;
}

From source file:com.hp.autonomy.hod.client.api.authentication.SignedRequest.java

static SignedRequest sign(final Hmac hmac, final String endpoint,
        final AuthenticationToken<?, TokenType.HmacSha1> token, final Request<String, String> request) {
    final URIBuilder uriBuilder;

    try {//  w w w  . j a  va2 s . co  m
        uriBuilder = new URIBuilder(endpoint + request.getPath());
    } catch (final URISyntaxException e) {
        throw new IllegalArgumentException("Invalid endpoint or request path");
    }

    if (request.getQueryParameters() != null) {
        for (final Map.Entry<String, List<String>> entry : request.getQueryParameters().entrySet()) {
            for (final String value : entry.getValue()) {
                uriBuilder.addParameter(entry.getKey(), value);
            }
        }
    }

    final String bodyString;

    if (request.getBody() == null) {
        bodyString = null;
    } else {
        final List<NameValuePair> pairs = new LinkedList<>();

        for (final Map.Entry<String, List<String>> entry : request.getBody().entrySet()) {
            pairs.addAll(entry.getValue().stream().map(value -> new BasicNameValuePair(entry.getKey(), value))
                    .collect(Collectors.toList()));
        }

        bodyString = URLEncodedUtils.format(pairs, UTF8);
    }

    final String tokenString = hmac.generateToken(request, token);
    return new SignedRequest(uriBuilder.toString(), request.getVerb(), bodyString, tokenString);
}

From source file:gobblin.util.FileListUtils.java

public static List<FileStatus> listMostNestedPathRecursively(FileSystem fs, Iterable<Path> paths)
        throws IOException {
    List<FileStatus> results = Lists.newArrayList();
    for (Path path : paths) {
        results.addAll(listMostNestedPathRecursively(fs, path));
    }/*from   w  w  w  .  j a  va  2 s .  c o m*/
    return results;
}

From source file:eu.annocultor.utils.SparqlQueryHelper.java

public static void filter(Namespaces namespaces, String namespacePrefix, String outputFilePrefix, String query,
        String... inputFilePattern) throws Exception {

    List<File> files = new ArrayList<File>();
    for (String pattern : inputFilePattern) {
        files.addAll(Utils.expandFileTemplateFrom(new File("."), pattern));
    }/*  w  w w .  j  a  v a2 s  .com*/
    SparqlQueryHelper sqh = new SparqlQueryHelper(namespacePrefix);
    try {
        sqh.open();
        sqh.load(namespacePrefix, files.toArray(new File[] {}));
        sqh.query(query);
        sqh.save(namespaces, outputFilePrefix);
    } finally {
        sqh.close();
    }
}