package org.granchi.hollywood;

import rx.Observable;

/**
 * Transformer to use in Model Observable, so an Actor can receive only a class of Model he's
 * interested in.
 * <p/>
 * It is used as:
 * <pre>models.compose(modelOfType(SpecificModel.class)).subscribe(...)</pre>
 */
// TODO what if it's buried within TWO composite models?
// TODO wouldn't it be easier if if would get built as an getSubModelOfType(class) in Model
// class?
@Deprecated
public class ModelFilter {
    public static <M extends Model> Observable.Transformer<? super Model, M> modelOfType(Class<M>
                                                                                                 modelClass) {
        return observable -> observable
                .ofType(modelClass)
                .mergeWith(observable
                                   .ofType(CompositeModel.class)
                                   .flatMap(composite -> Observable.from(composite.getModels())
                                                                   .ofType(modelClass)));
    }
}
@@ -32,17 +32,27 @@
 %0Aimport 
-r
+io.reactive
 x.Observ
@@ -56,16 +56,59 @@
 ervable;
+%0Aimport io.reactivex.ObservableTransformer;
 %0A%0A/**%0A *
@@ -569,17 +569,16 @@
 servable
-.
 Transfor
@@ -620,17 +620,16 @@
 lass%3CM%3E%0A
- 
         
@@ -981,16 +981,24 @@
 ble.from
+Iterable
 (composi
@@ -999,16 +999,106 @@
 omposite
+%0A                                                                                         
 .getMode

Migrate to RxJava 2