Created
May 14, 2012 19:25
-
-
Save okram/2695866 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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