Initial import into git.
[galago.git] / java / galago / src / galago / tupleflow / Unique.java
blob43907d5aba8176b042076e67d67abfc6f264b395
1 /*
2 * Unique.java
4 * Created on October 18, 2006, 11:17 AM
6 * To change this template, choose Tools | Template Manager
7 * and open the template in the editor.
8 */
10 package galago.tupleflow;
12 import java.io.IOException;
13 import java.util.Comparator;
15 /**
17 * @author trevor
19 public class Unique<T> implements Processor<T> {
20 Comparator<T> sameObject;
21 T last;
22 Processor<T> processor;
24 /** Creates a new instance of Unique */
25 public Unique( Comparator<T> sameObject, Processor<T> processor ) {
26 this.sameObject = sameObject;
27 this.last = null;
28 this.processor = processor;
31 public void process( T object ) throws IOException {
32 if( last != null && 0 == sameObject.compare( object, last ) )
33 return;
35 processor.process(object);
36 last = object;
39 public void close() throws IOException {
40 last = null;
41 processor.close();