Java Code Examples for com.google.api.client.util.Lists#newArrayListWithCapacity()

The following examples show how to use com.google.api.client.util.Lists#newArrayListWithCapacity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Importer.java    From mail-importer with Apache License 2.0 6 votes vote down vote up
public void importMail() throws MessagingException, IOException {
  LocalStorage storage = storageProvider.get();
  gmailSyncer.init();

  int messagesImported = 0;
  Iterator<LocalMessage> iterator = storage.iterator();
  while (iterator.hasNext() && keepImporting(messagesImported)) {
    List<LocalMessage> batch = Lists.newArrayListWithCapacity(BATCH_SIZE);
    for (int i = 0;
         i < BATCH_SIZE
             && iterator.hasNext()
             && keepImporting(messagesImported);
         i++) {
      LocalMessage message = iterator.next();
      logger.fine(() -> "Id: " + message.getMessageId());
      logger.fine(() -> "Folders: " + message.getFolders());
      batch.add(message);
      messagesImported++;
    }
    gmailSyncer.sync(batch);
  }
}
 
Example 2
Source File: ArtifactServiceImpl.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
private static Pathable[] getArtifactPath(Job job, String srcDir) {
    String[] split = srcDir.split(Separator);
    List<Pathable> list = Lists.newArrayListWithCapacity(split.length + 3);

    list.add(job::getFlowId);
    list.add(job);
    list.add(JobArtifact.ArtifactPath);

    for (String dir : split) {
        list.add(new StringPath(dir));
    }

    return list.toArray(new Pathable[0]);
}
 
Example 3
Source File: ArtifactServiceImpl.java    From flow-platform-x with Apache License 2.0 5 votes vote down vote up
private static Pathable[] getArtifactPath(Job job, String srcDir) {
    String[] split = srcDir.split(Separator);
    List<Pathable> list = Lists.newArrayListWithCapacity(split.length + 3);

    list.add(job::getFlowId);
    list.add(job);
    list.add(JobArtifact.ArtifactPath);

    for (String dir : split) {
        list.add(new StringPath(dir));
    }

    return list.toArray(new Pathable[0]);
}