Coverage Report - org.galagosearch.tupleflow.Unique
 
Classes in this File Line Coverage Branch Coverage Complexity
Unique
0%
0/13
0%
0/4
0
 
 1  
 // BSD License (http://www.galagosearch.org/license)
 2  
 package org.galagosearch.tupleflow;
 3  
 
 4  
 import java.io.IOException;
 5  
 import java.util.Comparator;
 6  
 
 7  
 /**
 8  
  *
 9  
  * @author trevor
 10  
  */
 11  
 public class Unique<T> implements Processor<T> {
 12  
     Comparator<T> sameObject;
 13  
     T last;
 14  
     Processor<T> processor;
 15  
 
 16  
     /** Creates a new instance of Unique */
 17  0
     public Unique(Comparator<T> sameObject, Processor<T> processor) {
 18  0
         this.sameObject = sameObject;
 19  0
         this.last = null;
 20  0
         this.processor = processor;
 21  0
     }
 22  
 
 23  
     public void process(T object) throws IOException {
 24  0
         if (last != null && 0 == sameObject.compare(object, last)) {
 25  0
             return;
 26  
         }
 27  0
         processor.process(object);
 28  0
         last = object;
 29  0
     }
 30  
 
 31  
     public void close() throws IOException {
 32  0
         last = null;
 33  0
         processor.close();
 34  0
     }
 35  
 }