package com.wizzardo.tools.collections.flow.flows;

import com.wizzardo.tools.collections.flow.FlowProcessor;

import java.util.Comparator;

/**
 * Created by wizzardo on 16.04.16.
 */
public class FlowMinWithComparator<A> extends FlowProcessor<A, A> {
    private A min;
    private final Comparator<? super A> comparator;

    public FlowMinWithComparator(A def, Comparator<? super A> comparator) {
        this.comparator = comparator;
        min = def;
    }

    @Override
    public void process(A a) {
        if (min == null || comparator.compare(min, a) > 0)
            min = a;
    }

    @Override
    public A get() {
        return min;
    }
}

@@ -235,18 +235,21 @@
 wProcess
-or
+OnEnd
 %3CA, A%3E %7B
@@ -253,27 +253,8 @@
 %3E %7B%0A
-    private A min;%0A
     
@@ -424,19 +424,22 @@
         
-min
+result
  = def;%0A
@@ -502,19 +502,22 @@
     if (
-min
+result
  == null
@@ -539,19 +539,22 @@
 compare(
-min
+result
 , a) %3E 0
@@ -571,77 +571,18 @@
     
-min = a;%0A    %7D%0A%0A    @Override%0A    public A get() %7B%0A        return min
+result = a
 ;%0A  

update 'min with comparator'