com.googlecode.totallylazy.functions.Reducer Java Examples

The following examples show how to use com.googlecode.totallylazy.functions.Reducer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: covered_covered_t.java    From coming with MIT License 6 votes vote down vote up
private Sequence<Result> modifiedResults(final Object expressionInstance) {
    return sequence(expressionInstance.getClass().getDeclaredFields())
            .reduceLeft(new Reducer<Field, Sequence<Result>>() {
                public Sequence<Result> call(Sequence<Result> results, Field field) throws Exception {
                    Option<Result> result = result(field.getName()).filter(where(Result::value, not(equalTo(field.get(expressionInstance)))));

                    if (result.isEmpty())
                        return results;

                    return results.append(Result.result(field.getName(), field.get(expressionInstance)));

                }

                public Sequence<Result> identity() {
                    return empty(Result.class);
                }
            });
}
 
Example #2
Source File: covered_covered_s.java    From coming with MIT License 6 votes vote down vote up
private Sequence<Result> modifiedResults(final Object expressionInstance) {
    return sequence(expressionInstance.getClass().getDeclaredFields())
            .reduceLeft(new Reducer<Field, Sequence<Result>>() {
                public Sequence<Result> call(Sequence<Result> results, Field field) throws Exception {
                    Option<Result> result = result(field.getName()).filter(where(Result::value, not(equalTo(field.get(expressionInstance)))));

                    if (result.isEmpty())
                        return results;

                    return results.append(Result.result(field.getName(), field.get(expressionInstance)));

                }

                public Sequence<Result> identity() {
                    return empty(Result.class);
                }
            });
}
 
Example #3
Source File: Evaluator.java    From java-repl with Apache License 2.0 6 votes vote down vote up
private Sequence<Result> modifiedResults(final Object expressionInstance) {
    return sequence(expressionInstance.getClass().getDeclaredFields())
            .reduceLeft(new Reducer<Field, Sequence<Result>>() {
                public Sequence<Result> call(Sequence<Result> results, Field field) throws Exception {
                    Option<Result> result = result(field.getName()).filter(where(Result::value, not(equalTo(field.get(expressionInstance)))));

                    if (result.isEmpty())
                        return results;

                    return results.append(Result.result(field.getName(), field.get(expressionInstance)));

                }

                public Sequence<Result> identity() {
                    return empty(Result.class);
                }
            });
}
 
Example #4
Source File: SelectionTest.java    From totallylazy with Apache License 2.0 5 votes vote down vote up
static <T, R> Aggregate<T, R> aggregate(Keyword<? extends T> keyword, Reducer<? super T, R> reducer) {
    return new Aggregate<T, R>() {
        @Override
        public Keyword<? extends T> keyword() {
            return keyword;
        }

        @Override
        public Reducer<? super T, R> reducer() {
            return reducer;
        }
    };
}
 
Example #5
Source File: Transducer.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
default <C> Transducer<A, C> scan(Reducer<? super B, C> reducer) {
    return compose(Transducers.scan(reducer));
}
 
Example #6
Source File: Transducer.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
default <C> Transducer<A, C> reduce(Reducer<? super B, C> reducer) {
    return compose(Transducers.reduce(reducer));
}
 
Example #7
Source File: Sender.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
default <B> Sender<B> scan(Reducer<? super A, B> reducer) {
    return transduce(Transducers.scan(reducer));
}
 
Example #8
Source File: Sender.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
default <B> Sender<B> reduce(Reducer<? super A, B> reducer) {
    return transduce(Transducers.reduce(reducer));
}
 
Example #9
Source File: Transducers.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
static <A, B> Transducer<A, B> scan(Reducer<? super A, B> reducer) {
    return ScanTransducer.scanTransducer(reducer);
}
 
Example #10
Source File: Transducers.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
static <A, B> Transducer<A, B> reduce(Reducer<? super A, B> reducer) {
    return compose(scan(reducer), last());
}
 
Example #11
Source File: ScanTransducer.java    From totallylazy with Apache License 2.0 4 votes vote down vote up
static <A, B> ScanTransducer<A, B> scanTransducer(Reducer<? super A, B> reducer) {
    return scanTransducer(reducer.identity(), reducer);
}
 
Example #12
Source File: SelectionTest.java    From totallylazy with Apache License 2.0 votes vote down vote up
Reducer<? super T, R> reducer();