<commit_before>package com.tinkerpop.pipes.filter;

import com.tinkerpop.pipes.AbstractPipe;
import com.tinkerpop.pipes.PipeClosure;

/**
 * FilterClosurePipe is a generic filter pipe.
 * It takes a PipeClosure that returns an Object for in its compute() step when the argument is the start of the pipe.
 * If the return is true (or non-null), then start is emitted. Otherwise, the start is not emitted.
 *
 * @author <NAME> (http://markorodriguez.com)
 */
public class FilterClosurePipe<S> extends AbstractPipe<S, S> implements FilterPipe<S> {

    private final PipeClosure closure;

    public FilterClosurePipe(final PipeClosure closure) {
        this.closure = closure;
        this.closure.setPipe(this);
    }

    public S processNextStart() {
        while (true) {
            final S start = this.starts.next();
            final Object result = closure.compute(start);
            if (result instanceof Boolean) {
                if ((Boolean) result)
                    return start;
            } else if (null != result)
                return start;
        }
    }
}<commit_msg>FilterClosurePipe is no longer Groovy truth, but Java truth.<commit_after>package com.tinkerpop.pipes.filter;

import com.tinkerpop.pipes.AbstractPipe;
import com.tinkerpop.pipes.Pipe;
import com.tinkerpop.pipes.PipeClosure;

/**
 * FilterClosurePipe is a generic filter pipe.
 * It takes a PipeClosure that returns an Object for in its compute() step when the argument is the start of the pipe.
 * If the return is true (or non-null), then start is emitted. Otherwise, the start is not emitted.
 *
 * @author <NAME> (http://markorodriguez.com)
 */
public class FilterClosurePipe<S> extends AbstractPipe<S, S> implements FilterPipe<S> {

    private final PipeClosure<Boolean, Pipe> closure;

    public FilterClosurePipe(final PipeClosure<Boolean, Pipe> closure) {
        this.closure = closure;
        this.closure.setPipe(this);
    }

    public S processNextStart() {
        while (true) {
            final S start = this.starts.next();
            if (closure.compute(start))
                return start;
        }
    }
}
{'fraction_non_alphanumeric': 0.09342723004694836, 'fraction_numerical': 0.0, 'mean_word_length': 2.83273381294964, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5043472', 'n_tokens_mistral': 664, 'n_tokens_neox': 623, 'n_words': 199}