Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/main/java/rx/observables/MathObservable.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import rx.Observable;
import rx.functions.Func1;
import rx.functions.Functions;
import rx.math.operators.OperatorMinMax;
import rx.math.operators.OperatorSum;
import rx.math.operators.OperatorAverageDouble;
Expand All @@ -38,6 +37,18 @@ private MathObservable(Observable<T> o) {
public static <T> MathObservable<T> from(Observable<T> o) {
return new MathObservable<T>(o);
}

@SuppressWarnings("rawtypes")
private static Func1 INDENTITY = new Func1() {
@Override
public Object call(Object t1) {
return t1;
}
};
@SuppressWarnings("unchecked")
private static <T> Func1<T, T> identity() {
return INDENTITY;
}

/**
* Returns an Observable that emits the average of the Doubles emitted by the source Observable.
Expand All @@ -52,7 +63,7 @@ public static <T> MathObservable<T> from(Observable<T> o) {
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
*/
public final static Observable<Double> averageDouble(Observable<Double> source) {
return source.lift(new OperatorAverageDouble<Double>(Functions.<Double>identity()));
return source.lift(new OperatorAverageDouble<Double>(MathObservable.<Double>identity()));
}

/**
Expand All @@ -68,7 +79,7 @@ public final static Observable<Double> averageDouble(Observable<Double> source)
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
*/
public final static Observable<Float> averageFloat(Observable<Float> source) {
return source.lift(new OperatorAverageFloat<Float>(Functions.<Float>identity()));
return source.lift(new OperatorAverageFloat<Float>(MathObservable.<Float>identity()));
}

/**
Expand All @@ -86,7 +97,7 @@ public final static Observable<Float> averageFloat(Observable<Float> source) {
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
*/
public final static Observable<Integer> averageInteger(Observable<Integer> source) {
return source.lift(new OperatorAverageInteger<Integer>(Functions.<Integer>identity()));
return source.lift(new OperatorAverageInteger<Integer>(MathObservable.<Integer>identity()));
}

/**
Expand All @@ -102,7 +113,7 @@ public final static Observable<Integer> averageInteger(Observable<Integer> sourc
* @see <a href="http://msdn.microsoft.com/en-us/library/system.reactive.linq.observable.average.aspx">MSDN: Observable.Average</a>
*/
public final static Observable<Long> averageLong(Observable<Long> source) {
return source.lift(new OperatorAverageLong<Long>(Functions.<Long>identity()));
return source.lift(new OperatorAverageLong<Long>(MathObservable.<Long>identity()));
}

/**
Expand Down