Java Collections.addAll Examples

Java Collections.addAll - 30 examples found. These are the top rated real world Java examples of java.util.Collections.addAll extracted from open source projects. You can rate examples to help us improve the quality of examples.
 private void editSpeakertable() {
   BasicTranscription transcription = table.getModel().getTranscription();
   String[] speakerIDsBefore = transcription.getHead().getSpeakertable().getAllSpeakerIDs();
   int[] tiersWithAutoDisplayName = transcription.getTierNumbersWithAutoDisplayName();
   EditSpeakerTableDialog dialog =
       new EditSpeakerTableDialog(table.parent, true, transcription.getHead().getSpeakertable());
   if (dialog.editSpeakertable()) {
     transcription.getHead().setSpeakertable(dialog.getSpeakertable());
     table.getModel().getTranscription().checkSpeakers();
     if (dialog.getAutoAdd()) {
       // auto add tiers for new speakers
       HashSet<String> before = new HashSet<String>();
       Collections.addAll(before, speakerIDsBefore);
       HashSet<String> after = new HashSet<String>();
       Collections.addAll(after, dialog.getSpeakertable().getAllSpeakerIDs());
       if (after.removeAll(before)) {
         for (String newID : after) {
           Tier newTier = new Tier(transcription.getBody().getFreeID(), newID, "v", "t");
           String displayName = newTier.getDescription(dialog.getSpeakertable());
           newTier.setDisplayName(displayName);
           table.getModel().addTier(newTier);
           System.out.println("Tier inserted for " + newID);
         }
       }
     }
     transcription.makeAutoDisplayName(tiersWithAutoDisplayName);
     table.getModel().fireRowLabelsChanged();
     table.transcriptionChanged = true;
     table.status("Speaker table edited");
   }
 }
  public void testRegisteredQueries() throws IOException {
    SearchModule module = new SearchModule(Settings.EMPTY, false, emptyList());
    List<String> allSupportedQueries = new ArrayList<>();
    Collections.addAll(allSupportedQueries, NON_DEPRECATED_QUERIES);
    Collections.addAll(allSupportedQueries, DEPRECATED_QUERIES);
    String[] supportedQueries = allSupportedQueries.toArray(new String[allSupportedQueries.size()]);
    assertThat(module.getQueryParserRegistry().getNames(), containsInAnyOrder(supportedQueries));

    IndicesQueriesRegistry indicesQueriesRegistry = module.getQueryParserRegistry();
    XContentParser dummyParser = XContentHelper.createParser(new BytesArray("{}"));
    for (String queryName : supportedQueries) {
      indicesQueriesRegistry.lookup(
          queryName, ParseFieldMatcher.EMPTY, dummyParser.getTokenLocation());
    }

    for (String queryName : NON_DEPRECATED_QUERIES) {
      QueryParser<?> queryParser =
          indicesQueriesRegistry.lookup(
              queryName, ParseFieldMatcher.STRICT, dummyParser.getTokenLocation());
      assertThat(queryParser, notNullValue());
    }
    for (String queryName : DEPRECATED_QUERIES) {
      try {
        indicesQueriesRegistry.lookup(
            queryName, ParseFieldMatcher.STRICT, dummyParser.getTokenLocation());
        fail("query is deprecated, getQueryParser should have failed in strict mode");
      } catch (IllegalArgumentException e) {
        assertThat(e.getMessage(), containsString("Deprecated field [" + queryName + "] used"));
      }
    }
  }
 @Override
 public Authorizations getAuthorizations(User user, String... additionalAuthorizations) {
   List<String> auths = new ArrayList<>();
   Collections.addAll(auths, ((InMemoryUser) user).getAuthorizations());
   Collections.addAll(auths, additionalAuthorizations);
   return this.graph.createAuthorizations(auths.toArray(new String[auths.size()]));
 }
  @Override
  protected List<Object> getKeys() {

    List<Object> keys = new ArrayList<Object>();

    List<IConfigurationElement> proxyElements =
        ToolchainExtensions.getInstance().findExplorerProxyNodes(element);

    List<IConfigurationElement> children = new ArrayList<IConfigurationElement>();
    Collections.addAll(children, element.getChildren());

    for (IConfigurationElement proxy : proxyElements) {
      Collections.addAll(children, proxy.getChildren());
    }

    for (IConfigurationElement el : children) {

      if (ToolchainExtensions.NODE_EXTENSION_NAME.equals(el.getName())) {
        keys.add(new Key(el, null));
      }

      if (ToolchainExtensions.NODE_RESOURCE_EXTENSION_NAME.equals(el.getName())) {
        keys.add(new Key(el, null));
      }

      if (ToolchainExtensions.NODE_DYNAMIC_EXTENSION_NAME.equals(el.getName())) {
        try {
          IExplorerContentRetriever contentRetriever = contentRetrievers.get(el);
          if (contentRetriever == null) {
            contentRetriever = (IExplorerContentRetriever) el.createExecutableExtension("class");
            contentRetriever.initialize(el.getAttribute("id"), getNode().getContext());
            contentRetriever.addPropertyChangeListener(contentRetrieverListener);
            contentRetrievers.put(el, contentRetriever);
          }

          if (contentRetriever != null) {

            List<Object> contentList = contentRetriever.getChildren();
            if (contentList.isEmpty()) {

              String emptyNodeID = el.getAttribute("empty");
              if (emptyNodeID != null && !emptyNodeID.isEmpty()) {
                keys.add(new Key(el, null));
              }

            } else {
              for (Object content : contentList) {
                keys.add(new Key(el, content));
              }
            }
          }

        } catch (CoreException e) {
          e.printStackTrace();
        }
      }
    }

    return keys;
  }
Example #5
0
  public Game(IGameControl control, String... playerNames) {
    players = new Player[playerNames.length];
    for (int i = 0; i < players.length; i++) {
      players[i] = new Player(playerNames[i], i, Color.PINK, control, this);
    }

    this.control = control;

    IBoardBuilder builder = new EasyBoardBuilder();
    Collections.addAll(intersections, builder.getIntersections());
    Collections.addAll(paths, builder.getPaths());
    terrains = builder.getTerrains();

    for (Intersection i : intersections) {
      control.sendGameEvent(i.createSetupEvent());
    }

    for (Path p : paths) {
      control.sendGameEvent(p.createSetupEvent());
    }

    for (Terrain t : terrains) {
      control.sendGameEvent(t.createSetupEvent());
    }

    control.sendGameEvent(new PreparationSettlementPhaseEvent(curPlayerIndex));
  }
Example #6
0
  /**
   * Create ProcessBuilder using the java launcher from the jdk to be tested, and with any platform
   * specific arguments prepended.
   *
   * @param addTestVmAndJavaOptions If true, adds test.vm.opts and test.java.opts to the java
   *     arguments.
   * @param command Arguments to pass to the java command.
   * @return The ProcessBuilder instance representing the java command.
   */
  public static ProcessBuilder createJavaProcessBuilder(
      boolean addTestVmAndJavaOptions, String... command) throws Exception {
    String javapath = JDKToolFinder.getJDKTool("java");

    ArrayList<String> args = new ArrayList<>();
    args.add(javapath);
    Collections.addAll(args, getPlatformSpecificVMArgs());

    if (addTestVmAndJavaOptions) {
      // -cp is needed to make sure the same classpath is used whether the test is
      // run in AgentVM mode or OtherVM mode. It was added to the hotspot version
      // of this API as part of 8077608. However, for the jdk version it is only
      // added when addTestVmAndJavaOptions is true in order to minimize
      // disruption to existing JDK tests, which have yet to be tested with -cp
      // being added. At some point -cp should always be added to be consistent
      // with what the hotspot version does.
      args.add("-cp");
      args.add(System.getProperty("java.class.path"));
      Collections.addAll(args, Utils.getTestJavaOpts());
    }

    Collections.addAll(args, command);

    // Reporting
    StringBuilder cmdLine = new StringBuilder();
    for (String cmd : args) cmdLine.append(cmd).append(' ');
    System.out.println("Command line: [" + cmdLine.toString() + "]");

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