com.hubspot.imap.protocol.command.fetch.StreamingFetchCommand Maven / Gradle / Ivy
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);
}
}