All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.imap.protocol.command.fetch.StreamingFetchCommand Maven / Gradle / Ivy

There is a newer version: 0.6.1
Show newest version
package com.hubspot.imap.protocol.command.fetch;

import com.google.common.collect.Lists;
import com.hubspot.imap.protocol.command.fetch.items.FetchDataItem;
import com.hubspot.imap.protocol.message.ImapMessage;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;

public class StreamingFetchCommand extends FetchCommand {

  private final Function messageConsumer;

  public StreamingFetchCommand(
    long startId,
    Optional stopId,
    Function messageConsumer,
    List fetchDataItems
  ) {
    super(startId, stopId, fetchDataItems);
    this.messageConsumer = messageConsumer;
  }

  public StreamingFetchCommand(
    long startId,
    Optional stopId,
    Function messageConsumer,
    FetchDataItem item,
    FetchDataItem... otherItems
  ) {
    this(startId, stopId, messageConsumer, Lists.asList(item, otherItems));
  }

  public R handle(ImapMessage message) {
    return messageConsumer.apply(message);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy