Skip to content

Instantly share code, notes, and snippets.

@okram
Created May 14, 2012 19:25
Show Gist options
  • Save okram/2695866 to your computer and use it in GitHub Desktop.
Save okram/2695866 to your computer and use it in GitHub Desktop.
package com.tinkerpop.gremlin.pipes.filter;
import com.tinkerpop.blueprints.Element;
import com.tinkerpop.pipes.AbstractPipe;
import com.tinkerpop.pipes.filter.FilterPipe;
import com.tinkerpop.pipes.util.PipeHelper;
/**
* @author Marko A. Rodriguez (http://markorodriguez.com)
*/
public class IntervalFilterPipe<T extends Element> extends AbstractPipe<T, T> implements FilterPipe<T> {
private final String key;
private final Object startValue;
private final Object endValue;
public IntervalFilterPipe(final String key, final Object startValue, final Object endValue) {
this.key = key;
this.startValue = startValue;
this.endValue = endValue;
}
public T processNextStart() {
while (true) {
final T t = this.starts.next();
final Object value = t.getProperty(key);
if (null == value)
continue;
else {
if (PipeHelper.compareObjects(Filter.GREATER_THAN, value, this.startValue) && PipeHelper.compareObjects(Filter.LESS_THAN_EQUAL, value, this.endValue))
return t;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment