diff --git a/store2store/src/main/java/com/playmoweb/store2store/store/StoreDao.java b/store2store/src/main/java/com/playmoweb/store2store/store/StoreDao.java index 2492961..9821c76 100644 --- a/store2store/src/main/java/com/playmoweb/store2store/store/StoreDao.java +++ b/store2store/src/main/java/com/playmoweb/store2store/store/StoreDao.java @@ -6,6 +6,7 @@ import java.util.List; import io.reactivex.Flowable; +import io.reactivex.functions.Function; /** * @author Thibaud Giovannetti @@ -78,4 +79,23 @@ public Flowable delete(final T item) { public Flowable deleteAll() { throw new UnsupportedOperationException("This method has not been implemented in the child class"); } + + /** + * Wrap an object into an flowable optional + */ + protected Flowable> wrapOptional(S obj){ + return Flowable.just(Optional.wrap(obj)); + } + + /** + * Wrap a flowable object into an flowable optional + */ + protected Flowable> wrapOptional(Flowable obj){ + return obj.flatMap(new Function>>() { + @Override + public Flowable> apply(S s) throws Exception { + return wrapOptional(s); + } + }); + } } diff --git a/store2store/src/main/java/com/playmoweb/store2store/store/StoreService.java b/store2store/src/main/java/com/playmoweb/store2store/store/StoreService.java index 5f94f1a..53a9055 100644 --- a/store2store/src/main/java/com/playmoweb/store2store/store/StoreService.java +++ b/store2store/src/main/java/com/playmoweb/store2store/store/StoreService.java @@ -591,23 +591,4 @@ public Flowable apply(Optional reinsertedItem) throws Exception { flowables.add(flowStorage); return Flowable.concat(flowables); } - - /** - * Wrap an object into an flowable optional - */ - public Flowable> wrapOptional(S obj){ - return Flowable.just(Optional.wrap(obj)); - } - - /** - * Wrap a flowable object into an flowable optional - */ - public Flowable> wrapOptional(Flowable obj){ - return obj.flatMap(new Function>>() { - @Override - public Flowable> apply(S s) throws Exception { - return wrapOptional(s); - } - }); - } }