本文整理汇总了Java中rx.CovarianceTest.HorrorMovie类的典型用法代码示例。如果您正苦于以下问题:Java HorrorMovie类的具体用法?Java HorrorMovie怎么用?Java HorrorMovie使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HorrorMovie类属于rx.CovarianceTest包,在下文中一共展示了HorrorMovie类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reduceWithObjects
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void reduceWithObjects() {
Observable<Movie> horrorMovies = Observable.<Movie> just(new HorrorMovie());
BiFunction<Movie, Movie, Movie> chooseSecondMovie =
new BiFunction<Movie, Movie, Movie>() {
@Override
public Movie call(Movie t1, Movie t2) {
return t2;
}
};
Observable<Movie> reduceResult = horrorMovies.scan(chooseSecondMovie).takeLast(1);
Observable<Movie> reduceResult2 = horrorMovies.reduce(chooseSecondMovie);
}
示例2: reduceWithCovariantObjects
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
/**
* Reduce consumes and produces T so can't do covariance.
*
* https://github.com/ReactiveX/RxJava/issues/360#issuecomment-24203016
*/
@SuppressWarnings("unused")
@Test
public void reduceWithCovariantObjects() {
Observable<Movie> horrorMovies = Observable.<Movie> just(new HorrorMovie());
BiFunction<Movie, Movie, Movie> chooseSecondMovie =
new BiFunction<Movie, Movie, Movie>() {
@Override
public Movie call(Movie t1, Movie t2) {
return t2;
}
};
Observable<Movie> reduceResult2 = horrorMovies.reduce(chooseSecondMovie);
}
示例3: testMergeCovariance4
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testMergeCovariance4() {
Observable<Movie> o1 = Observable.create(o -> {
AbstractSubscription.setEmptyOn(o);
o.onNext(new HorrorMovie());
o.onNext(new Movie());
// o.onNext(new Media()); // correctly doesn't compile
o.onComplete();
});
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());
List<Media> values = Observable.merge(o1, o2).toList().toBlocking().single();
assertTrue(values.get(0) instanceof HorrorMovie);
assertTrue(values.get(1) instanceof Movie);
assertTrue(values.get(2) != null);
assertTrue(values.get(3) instanceof HorrorMovie);
}
示例4: testConcatCovariance
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testConcatCovariance() {
HorrorMovie horrorMovie1 = new HorrorMovie();
Movie movie = new Movie();
Media media = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();
Observable<Media> o1 = Observable.<Media> just(horrorMovie1, movie);
Observable<Media> o2 = Observable.just(media, horrorMovie2);
Observable<Observable<Media>> os = Observable.just(o1, o2);
List<Media> values = Observable.concat(os).toList().toBlocking().single();
assertEquals(horrorMovie1, values.get(0));
assertEquals(movie, values.get(1));
assertEquals(media, values.get(2));
assertEquals(horrorMovie2, values.get(3));
assertEquals(4, values.size());
}
示例5: testConcatCovariance2
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testConcatCovariance2() {
HorrorMovie horrorMovie1 = new HorrorMovie();
Movie movie = new Movie();
Media media1 = new Media();
Media media2 = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();
Observable<Media> o1 = Observable.just(horrorMovie1, movie, media1);
Observable<Media> o2 = Observable.just(media2, horrorMovie2);
Observable<Observable<Media>> os = Observable.just(o1, o2);
List<Media> values = Observable.concat(os).toList().toBlocking().single();
assertEquals(horrorMovie1, values.get(0));
assertEquals(movie, values.get(1));
assertEquals(media1, values.get(2));
assertEquals(media2, values.get(3));
assertEquals(horrorMovie2, values.get(4));
assertEquals(5, values.size());
}
示例6: testConcatCovariance3
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testConcatCovariance3() {
HorrorMovie horrorMovie1 = new HorrorMovie();
Movie movie = new Movie();
Media media = new Media();
HorrorMovie horrorMovie2 = new HorrorMovie();
Observable<Movie> o1 = Observable.just(horrorMovie1, movie);
Observable<Media> o2 = Observable.just(media, horrorMovie2);
List<Media> values = Observable.concat(o1, o2).toList().toBlocking().single();
assertEquals(horrorMovie1, values.get(0));
assertEquals(movie, values.get(1));
assertEquals(media, values.get(2));
assertEquals(horrorMovie2, values.get(3));
assertEquals(4, values.size());
}
示例7: reduceWithObjects
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@SuppressWarnings("unused")
@Test
public void reduceWithObjects() {
Observable<Movie> horrorMovies = Observable.<Movie> from(new HorrorMovie());
Func2<Movie, Movie, Movie> chooseSecondMovie =
new Func2<Movie, Movie, Movie>() {
public Movie call(Movie t1, Movie t2) {
return t2;
}
};
Observable<Movie> reduceResult = horrorMovies.scan(chooseSecondMovie).takeLast(1);
Observable<Movie> reduceResult2 = horrorMovies.reduce(chooseSecondMovie);
}
示例8: testMergeCovariance4
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testMergeCovariance4() {
Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() {
@Override
public Subscription onSubscribe(Observer<? super Movie> o) {
o.onNext(new HorrorMovie());
o.onNext(new Movie());
// o.onNext(new Media()); // correctly doesn't compile
o.onCompleted();
return Subscriptions.empty();
}
});
Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
List<Media> values = Observable.merge(o1, o2).toList().toBlockingObservable().single();
assertTrue(values.get(0) instanceof HorrorMovie);
assertTrue(values.get(1) instanceof Movie);
assertTrue(values.get(2) instanceof Media);
assertTrue(values.get(3) instanceof HorrorMovie);
}
示例9: testConcatCovariance4
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testConcatCovariance4() {
Observable<Movie> o1 = Observable.create(new OnSubscribeFunc<Movie>() {
@Override
public Subscription onSubscribe(Observer<? super Movie> o) {
o.onNext(new HorrorMovie());
o.onNext(new Movie());
// o.onNext(new Media()); // correctly doesn't compile
o.onCompleted();
return Subscriptions.empty();
}
});
Observable<Media> o2 = Observable.from(new Media(), new HorrorMovie());
List<Media> values = Observable.concat(o1, o2).toList().toBlockingObservable().single();
assertTrue(values.get(0) instanceof HorrorMovie);
assertTrue(values.get(1) instanceof Movie);
assertTrue(values.get(2) instanceof Media);
assertTrue(values.get(3) instanceof HorrorMovie);
}
示例10: testCovarianceOfZip
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
/**
* This won't compile if super/extends isn't done correctly on generics
*/
@Test
public void testCovarianceOfZip() {
Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
Observable<CoolRating> ratings = Observable.just(new CoolRating());
Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlocking().forEach(extendedAction);
Observable.<Media, Rating, Result> zip(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Media, Rating, ExtendedResult> zip(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Movie, CoolRating, Result> zip(horrors, ratings, combine);
}
示例11: reduceCovariance
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
/**
* Reduce consumes and produces T so can't do covariance.
*
* https://github.com/ReactiveX/RxJava/issues/360#issuecomment-24203016
*/
@Test
public void reduceCovariance() {
// must type it to <Movie>
Observable<Movie> horrorMovies = Observable.<Movie> just(new HorrorMovie());
libraryFunctionActingOnMovieObservables(horrorMovies);
}
示例12: testCovarianceOfCombineLatest
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
/**
* This won't compile if super/extends isn't done correctly on generics
*/
@Test
public void testCovarianceOfCombineLatest() {
Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
Observable<CoolRating> ratings = Observable.just(new CoolRating());
Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlocking().forEach(extendedAction);
Observable.<Media, Rating, Result> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Media, Rating, ExtendedResult> combineLatest(horrors, ratings, combine).toBlocking().forEach(action);
Observable.<Movie, CoolRating, Result> combineLatest(horrors, ratings, combine);
}
示例13: testCovarianceOfMerge
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
/**
* This won't compile if super/extends isn't done correctly on generics
*/
@Test
public void testCovarianceOfMerge() {
Observable<HorrorMovie> horrors = Observable.just(new HorrorMovie());
Observable<Observable<HorrorMovie>> metaHorrors = Observable.just(horrors);
Observable.<Media> merge(metaHorrors);
}
示例14: testMergeCovariance
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testMergeCovariance() {
Observable<Media> o1 = Observable.<Media> just(new HorrorMovie(), new Movie());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());
Observable<Observable<Media>> os = Observable.just(o1, o2);
List<Media> values = Observable.merge(os).toList().toBlocking().single();
assertEquals(4, values.size());
}
示例15: testMergeCovariance2
import rx.CovarianceTest.HorrorMovie; //导入依赖的package包/类
@Test
public void testMergeCovariance2() {
Observable<Media> o1 = Observable.just(new HorrorMovie(), new Movie(), new Media());
Observable<Media> o2 = Observable.just(new Media(), new HorrorMovie());
Observable<Observable<Media>> os = Observable.just(o1, o2);
List<Media> values = Observable.merge(os).toList().toBlocking().single();
assertEquals(5, values.size());
}