Java Code Examples for java.util.Collections.addAll()

The following are Jave code examples for showing how to use addAll() of the java.util.Collections class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: TextHIN   File:   Source Code and License Vote up 6 votes
public static List<Map<String, String>> extractNamesFromResults(NodeList results, String[] names) {
	Set<String> exNames = new HashSet<>();
	List<Map<String, String>> values = new ArrayList<>();
	Collections.addAll(exNames, names);
	for (int i = 0; i < results.getLength(); i++) {
		NodeList bindings = ((Element) results.item(i)).getElementsByTagName("binding");
		Map<String, String> value = new HashMap<>();
		for (int j = 0; j < bindings.getLength(); j++) {
			Element binding = (Element) bindings.item(j);
			String var = binding.getAttribute("name");
			if (exNames.contains(var)) {
				String uri = SparqlExecutor.getTagValue("uri", binding);
				if (!(uri == null))
					value.put(var, FreebaseInfo.uri2id(uri));

		if (value.size() == exNames.size())
	return values;
Example 2
Project: OpenVertretung   File:   Source Code and License Vote up 6 votes
 * Get a comma separated list of all a database's SQL keywords that are NOT also SQL92/SQL2003 keywords.
 * @return the list
 * @throws SQLException
public String getSQLKeywords() throws SQLException {
    if (mysqlKeywords != null) {
        return mysqlKeywords;

    synchronized (DatabaseMetaData.class) {
        // double check, maybe it's already set
        if (mysqlKeywords != null) {
            return mysqlKeywords;

        Set<String> mysqlKeywordSet = new TreeSet<String>();
        StringBuilder mysqlKeywordsBuffer = new StringBuilder();

        Collections.addAll(mysqlKeywordSet, MYSQL_KEYWORDS);
        mysqlKeywordSet.removeAll(Arrays.asList(Util.isJdbc4() ? SQL2003_KEYWORDS : SQL92_KEYWORDS));

        for (String keyword : mysqlKeywordSet) {

        mysqlKeywords = mysqlKeywordsBuffer.substring(1);
        return mysqlKeywords;
Example 3
Project: minicraft-plus-revived   File:   Source Code and License Vote up 6 votes
public void writePrefs(String filename) {
	List<String> keyPairs = new ArrayList<>();
	Collections.addAll(keyPairs, Game.input.getKeyPrefs());
	data.add(String.join(":", keyPairs.toArray(new String[keyPairs.size()])));
	writeToFile(location + filename + extension, data);
Example 4
Project: openjdk-jdk10   File:   Source Code and License Vote up 6 votes
private static OutputAnalyzer runTest(boolean verifySilently) throws Exception {
  ArrayList<String> vmOpts = new ArrayList();

  Collections.addAll(vmOpts, Utils.getFilteredTestJavaOpts("-Xlog.*"));
  Collections.addAll(vmOpts, new String[] {"-XX:+UnlockDiagnosticVMOptions",
                                           (verifySilently ? "-Xlog:gc":"-Xlog:gc+verify=debug"),
  ProcessBuilder pb =
    ProcessTools.createJavaProcessBuilder(vmOpts.toArray(new String[vmOpts.size()]));
  OutputAnalyzer output = new OutputAnalyzer(pb.start());

  System.out.println("Output:\n" + output.getOutput());
  return output;
Example 5
Project: pnc-repressurized   File:   Source Code and License Vote up 6 votes
 * allows items to add custom lines of information to the mouseover description
public void addInformation(ItemStack remote, World world, List<String> curInfo, ITooltipFlag moreInfo) {
    super.addInformation(remote, world, curInfo, moreInfo);
    NBTTagCompound tag = remote.getTagCompound();
    if (tag != null && tag.hasKey("securityX")) {
        int x = tag.getInteger("securityX");
        int y = tag.getInteger("securityY");
        int z = tag.getInteger("securityZ");
        int dimensionId = tag.getInteger("securityDimension");
        Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.boundToSecurityStation", dimensionId, x, y, z), 40).split(System.getProperty("line.separator")));
    } else {
        Collections.addAll(curInfo, WordUtils.wrap(I18n.format("gui.remote.tooltip.rightClickToBind"), 40).split(System.getProperty("line.separator")));
Example 6
Project: oscm   File:   Source Code and License Vote up 6 votes
private Set<Filter> createFilterSet(String subscriptionId,
        String activationTime, String customerId, String customerName,
        String ServiceId) {
    final Filter subscriptionFilter = new Filter(
            TableColumns.SUBSCRIPTION_ID, subscriptionId);
    final Filter actTimeFilter = new Filter(TableColumns.ACTIVATION_TIME,
    final Filter orgIdFilter = new Filter(TableColumns.CUSTOMER_ID,
    final Filter orgNameFilter = new Filter(TableColumns.CUSTOMER_NAME,
    final Filter productIdFilter = new Filter(TableColumns.SERVICE_ID,
    Set<Filter> filterSet = new HashSet<>();
    Collections.addAll(filterSet, subscriptionFilter, actTimeFilter,
            orgIdFilter, orgNameFilter, productIdFilter);
    return filterSet;
Example 7
Project: cyberduck   File:   Source Code and License Vote up 5 votes
private static Set<File> listFiles(final File folder) {
    Set<File> files = new HashSet<File>();
    if(folder.isDirectory()) {
        final File[] children = folder.listFiles();
        if(null == children) {
            return files;
        Collections.addAll(files, children);
    return files;
Example 8
Project: Reer   File:   Source Code and License Vote up 5 votes
protected void addToolSpecificArgs(T spec, List<String> args) {
    Collections.addAll(args, "-x", getLanguage());
    if (spec.isPositionIndependentCode()) {
        if (!spec.getTargetPlatform().getOperatingSystem().isWindows()) {
Example 9
Project: letv   File:   Source Code and License Vote up 5 votes
public DanmakuContext addUserHashBlackList(String... hashes) {
    if (!(hashes == null || hashes.length == 0)) {
        Collections.addAll(this.mUserHashBlackList, hashes);
        setFilterData(DanmakuFilters.TAG_USER_HASH_FILTER, this.mUserHashBlackList);
        notifyConfigureChanged(DanmakuConfigTag.USER_HASH_BLACK_LIST, this.mUserHashBlackList);
    return this;
Example 10
Project: googles-monorepo-demo   File:   Source Code and License Vote up 5 votes
private static TestStringMultisetGenerator concurrentSkipListMultisetGenerator() {
  return new TestStringMultisetGenerator() {
    @Override protected Multiset<String> create(String[] elements) {
      Multiset<String> multiset = new ConcurrentHashMultiset<String>(
          new ConcurrentSkipListMap<String, AtomicInteger>());
      Collections.addAll(multiset, elements);
      return multiset;

    public List<String> order(List<String> insertionOrder) {
      return Ordering.natural().sortedCopy(insertionOrder);
Example 11
Project: Leanplum-Android-SDK   File:   Source Code and License Vote up 5 votes
 * Creates a new HashSet and adds the passed arguments to it.
 * @param items The items to add to the set.
 * @param <T> The type of the set to be created.
 * @return A typed set that contains the passed arguments.
static <T> HashSet<T> newHashSet(T... items) {
  HashSet<T> result = new HashSet<>((items != null) ? items.length : 0);
  if (items != null) {
    Collections.addAll(result, items);
  return result;
Example 12
Project: kafka-webview   File:   Source Code and License Vote up 5 votes
 * @return All of the option names, as a set.
public Set<String> getOptionsAsSet() {
    final Set<String> set = new HashSet<>();
    Collections.addAll(set, getOptions().split(","));
    return set;
Example 13
Project: elasticsearch_my   File:   Source Code and License Vote up 5 votes
 * Adds ids to the query.
public IdsQueryBuilder addIds(String... ids) {
    if (ids == null) {
        throw new IllegalArgumentException("[" + NAME + "] ids cannot be null");
    Collections.addAll(this.ids, ids);
    return this;
Example 14
Project: MinecraftMarket-Plugin   File:   Source Code and License Vote up 5 votes
 * find method by return value
 * @param type type of returned value
 * @return RefMethod
 * @throws RuntimeException if method not found
public RefMethod findMethodByReturnType(Class type) {
    if (type == null) type = void.class;
    List<Method> methods = new ArrayList<>();
    Collections.addAll(methods, clazz.getMethods());
    Collections.addAll(methods, clazz.getDeclaredMethods());
    for (Method m : methods) {
        if (type.equals(m.getReturnType())) {
            return new RefMethod(m);
    throw new RuntimeException("no such method");
Example 15
Project: openjdk-jdk10   File:   Source Code and License Vote up 5 votes
private List<String> validatedDependents( String dependent, String... otherDependents ) {
    List<String> dependents = new ArrayList<String>();
    dependents.add( dependent );
    Collections.addAll( dependents, otherDependents );

    for ( String each : dependents ) {
        if ( !parser.isRecognized( each ) )
            throw new UnconfiguredOptionException( each );

    return dependents;
Example 16
Project: SciChart.Android.Examples   File:   Source Code and License Vote up 5 votes
protected void initExample() {
    final IPieRenderableSeries pieSeries = sciChartBuilder.newPieSeries().withSeriesName("HowPeopleTravel").withSegments(
            sciChartBuilder.newPieSegment().withValue(34).withTitle("Ecologic").withRadialGradientColors(0xff84BC3D, 0xff5B8829).build(),
            sciChartBuilder.newPieSegment().withValue(34.4).withTitle("Municipal").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),
            sciChartBuilder.newPieSegment().withValue(31.6).withTitle("Personal").withRadialGradientColors(0xff4AB6C1, 0xff2182AD).build()

    final IPieRenderableSeries donutSeries = sciChartBuilder.newDonutSeries().withSeriesName("DetailedGroup").withSegments(
            sciChartBuilder.newPieSegment().withValue(28.8).withTitle("Walking").withRadialGradientColors(0xff84BC3D, 0xff5B8829).build(),
            sciChartBuilder.newPieSegment().withValue(5.2).withTitle("Bicycle").withRadialGradientColors(0xff84BC3D, 0xff5B8829).build(),

            sciChartBuilder.newPieSegment().withValue(12.3).withTitle("Metro").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),
            sciChartBuilder.newPieSegment().withValue(3.5).withTitle("Tram").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),
            sciChartBuilder.newPieSegment().withValue(5.9).withTitle("Rail").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),
            sciChartBuilder.newPieSegment().withValue(9.7).withTitle("Bus").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),
            sciChartBuilder.newPieSegment().withValue(3.0).withTitle("Taxi").withRadialGradientColors(0xffe04a2f, 0xffB7161B).build(),

            sciChartBuilder.newPieSegment().withValue(23.2).withTitle("Car").withRadialGradientColors(0xff4AB6C1, 0xff2182AD).build(),
            sciChartBuilder.newPieSegment().withValue(3.1).withTitle("Motorcycle").withRadialGradientColors(0xff4AB6C1, 0xff2182AD).build(),
            sciChartBuilder.newPieSegment().withValue(5.3).withTitle("Other").withRadialGradientColors(0xff4AB6C1, 0xff2182AD).build()

    Collections.addAll(pieChartSurface.getRenderableSeries(), pieSeries, donutSeries);
    Collections.addAll(pieChartSurface.getChartModifiers(), sciChartBuilder.newLegendModifier(legend).withShowCheckBoxes(false).withSourceSeries(pieSeries).build(), new PieChartTooltipModifier());

Example 17
Project: JAVA-   File:   Source Code and License Vote up 5 votes
 * Constructs an empty ArrayList.
public static final <E> ArrayList<E> newArrayList(E... e) {
    ArrayList<E> list = new ArrayList<E>();
    Collections.addAll(list, e);
    return list;
Example 18
Project: guava-mock   File:   Source Code and License Vote up 4 votes
@GwtIncompatible // NavigableMap
public void testAsMapNavigableReadsThrough() {
  NavigableSet<String> strings = Sets.newTreeSet();
  Collections.addAll(strings, "one", "two", "three");
  NavigableMap<String, Integer> map = Maps.asMap(strings, LENGTH_FUNCTION);
  assertEquals(ImmutableSortedMap.of("one", 3, "two", 3, "three", 5), map);
      ImmutableSortedMap.of("one", 3, "two", 3, "three", 5, "four", 4),
  assertEquals(Integer.valueOf(4), map.get("four"));
  SortedMap<String, Integer> headMap = map.headMap("two");
      ImmutableSortedMap.of("four", 4, "one", 3, "three", 5),
      ImmutableSortedMap.of("five", 4, "four", 4, "three", 5),
      mapEntry("five", 4),
      mapEntry("four", 4),
      mapEntry("three", 5),
      mapEntry("two", 3)).inOrder();

  NavigableMap<String, Integer> tailMap = map.tailMap("s", true);
  NavigableMap<String, Integer> subMap = map.subMap("a", true, "t", false);

      mapEntry("six", 3),
      mapEntry("three", 5)).inOrder();
      mapEntry("five", 4),
      mapEntry("four", 4),
      mapEntry("six", 3)).inOrder();
Example 19
Project: javaide   File:   Source Code and License Vote up 4 votes
private void createSupportLibFile(
        @NonNull File objFile,
        @NonNull Abi abi,
        @NonNull String soName,
        @NonNull CommandLineLauncher launcher,
        @NonNull Map<String, String> env) throws IOException, InterruptedException {

    // make sure the dest folder exist
    File abiFolder = new File(mLibOutputDir, abi.mDevice);
    if (!abiFolder.isDirectory() && !abiFolder.mkdirs()) {
        throw new IOException("Unable to create dir " + abiFolder.getAbsolutePath());

    File intermediatesFolder = new File(mRsLib, "intermediates");
    File intermediatesAbiFolder = new File(intermediatesFolder, abi.mDevice);
    File packagedFolder = new File(mRsLib, "packaged");
    File packagedAbiFolder = new File(packagedFolder, abi.mDevice);

    List<String> args = Lists.newArrayListWithExpectedSize(25);

    Collections.addAll(args, abi.mLinkerArgs);

    File outFile = new File(abiFolder, soName);

    args.add("-L" + intermediatesAbiFolder.getAbsolutePath());
    args.add("-L" + packagedAbiFolder.getAbsolutePath());


    args.add(new File(intermediatesAbiFolder, "libcompiler_rt.a").getAbsolutePath());


    File exe = new File(mBuildToolInfo.getPath(abi.mLinker));

    launcher.launch(exe, args, env);
Example 20
Project: s-store   File:   Source Code and License Vote up 3 votes
 * Creates a <i>mutable</i> {@code ArrayList} instance containing the given
 * elements.
 * <p><b>Note:</b> essentially the only reason to use this method is when you
 * will need to add or remove elements later. Otherwise, for non-null elements
 * use {@link ImmutableList#of()} (for varargs) or {@link
 * ImmutableList#copyOf(Object[])} (for an array) instead. If any elements
 * might be null, or you need support for {@link List#set(int, Object)}, use
 * {@link Arrays#asList}.
 * <p>Note that even when you do need the ability to add or remove, this method
 * provides only a tiny bit of syntactic sugar for {@code newArrayList(}{@link
 * Arrays#asList asList}{@code (...))}, or for creating an empty list then
 * calling {@link Collections#addAll}. This method is not actually very useful
 * and will likely be deprecated in the future.
@GwtCompatible(serializable = true)
public static <E> ArrayList<E> newArrayList(E... elements) {
  checkNotNull(elements); // for GWT
  // Avoid integer overflow when a large array is passed in
  int capacity = computeArrayListCapacity(elements.length);
  ArrayList<E> list = new ArrayList<E>(capacity);
  Collections.addAll(list, elements);
  return list;