1 package edu.uci.iotproject.comparison;
3 import edu.uci.iotproject.Conversation;
4 import edu.uci.iotproject.FlowPattern;
6 import java.util.concurrent.Callable;
7 import java.util.function.BiFunction;
10 * A task that compares a given {@link Conversation} and {@link FlowPattern} using a provided comparison function.
11 * The task implements {@link Callable} and can hence be executed on a background thread.
13 * @author Janus Varmarken {@literal <jvarmark@uci.edu>}
14 * @author Rahmadi Trimananda {@literal <rtrimana@uci.edu>}
16 public class PatternComparisonTask<R extends AbstractPatternComparisonResult<?>> implements Callable<R> {
18 private final Conversation mConversation;
19 private final FlowPattern mFlowPattern;
20 private final BiFunction<Conversation, FlowPattern, R> mComparitor;
23 * Create a new {@code PatternComparisonTask}.
25 * @param conversation The conversation to compare against {@code pattern}.
26 * @param pattern The pattern to compare against {@code conversation}.
27 * @param comparisonFunction The function that compares {@code pattern} and {@code conversation}.
29 public PatternComparisonTask(Conversation conversation, FlowPattern pattern, BiFunction<Conversation, FlowPattern, R> comparisonFunction) {
30 this.mConversation = conversation;
31 this.mFlowPattern = pattern;
32 this.mComparitor = comparisonFunction;
36 public R call() throws Exception {
37 return mComparitor.apply(mConversation, mFlowPattern);