public final class CacheableCompletable implements CompletableTransformer {

    private final String key;
    private final ObservableCache observableCache;

    public CacheableCompletable(String key, ObservableCache observableCache) {
        this.key = key;
        this.observableCache = observableCache;
    }

    @Override
    public CompletableSource apply(Completable upstream) {
        return observableCache.cacheCompletable(key, upstream);
    }
} public final class CacheableFlowable<T> implements FlowableTransformer<T, T> {

    private final String key;
    private final ObservableCache observableCache;

    public CacheableFlowable(String key, ObservableCache observableCache) {
        this.key = key;
        this.observableCache = observableCache;
    }

    @Override
    public Publisher<T> apply(Flowable<T> upstream) {
        return observableCache.cacheFlowable(key, upstream);
    }

} public final class CacheableMaybe<T> implements MaybeTransformer<T, T> {

    private final String key;
    private final ObservableCache observableCache;

    public CacheableMaybe(String key, ObservableCache observableCache) {
        this.key = key;
        this.observableCache = observableCache;
    }

    @Override
    public MaybeSource<T> apply(Maybe<T> upstream) {
        return observableCache.cacheMaybe(key, upstream);
    }
} public final class CacheableObservable<T> implements ObservableTransformer<T, T> {

    private final String key;
    private final ObservableCache observableCache;

    public CacheableObservable(String key, ObservableCache observableCache) {
        this.key = key;
        this.observableCache = observableCache;
    }

    @Override
    public ObservableSource<T> apply(Observable<T> upstream) {
        return observableCache.cacheObservable(key, upstream);
    }
} public final class CacheableSingle<T> implements SingleTransformer<T, T> {

    private final String key;
    private final ObservableCache observableCache;

    public CacheableSingle(String key, ObservableCache observableCache) {
        this.key = key;
        this.observableCache = observableCache;
    }

    @Override
    public SingleSource<T> apply(Single<T> upstream) {
        return observableCache.cacheSingle(key, upstream);
    }
} public final class CompletableFromCache extends ValueFromCache<Completable> {

    public CompletableFromCache() {
        this(null);
    }

    public CompletableFromCache(@Nullable Completable valueFromCache) {
        super(valueFromCache);
    }

    public static CompletableFromCache empty() {
        return new CompletableFromCache();
    }

    public static CompletableFromCache of(@Nullable Completable valueFromCache) {
        return new CompletableFromCache(valueFromCache);
    }

} public final class FlowableFromCache<T> extends ValueFromCache<Flowable<T>> {

    public FlowableFromCache() {
        this(null);
    }

    public FlowableFromCache(@Nullable Flowable<T> valueFromCache) {
        super(valueFromCache);
    }

    public static <T> FlowableFromCache<T> empty() {
        return new FlowableFromCache<>();
    }

    public static <T> FlowableFromCache<T> of(@Nullable Flowable<T> valueFromCache) {
        return new FlowableFromCache<>(valueFromCache);
    }

} public final class MaybeFromCache<T> extends ValueFromCache<Maybe<T>> {

    public MaybeFromCache() {
        this(null);
    }

    public MaybeFromCache(@Nullable Maybe<T> valueFromCache) {
        super(valueFromCache);
    }

    public static <T> MaybeFromCache<T> empty() {
        return new MaybeFromCache<>();
    }

    public static <T> MaybeFromCache<T> of(@Nullable Maybe<T> valueFromCache) {
        return new MaybeFromCache<>(valueFromCache);
    }

} public final class ObservableFromCache<T> extends ValueFromCache<Observable<T>> {

    public ObservableFromCache() {
        this(null);
    }

    public ObservableFromCache(@Nullable Observable<T> valueFromCache) {
        super(valueFromCache);
    }

    public static <T> ObservableFromCache<T> empty() {
        return new ObservableFromCache<>();
    }

    public static <T> ObservableFromCache<T> of(@Nullable Observable<T> valueFromCache) {
        return new ObservableFromCache<>(valueFromCache);
    }

} public final class SingleFromCache<T> extends ValueFromCache<Single<T>> {

    public SingleFromCache() {
        this(null);
    }

    public SingleFromCache(@Nullable Single<T> valueFromCache) {
        super(valueFromCache);
    }

    public static <T> SingleFromCache<T> empty() {
        return new SingleFromCache<>();
    }

    public static <T> SingleFromCache<T> of(@Nullable Single<T> valueFromCache) {
        return new SingleFromCache<>(valueFromCache);
    }

}
import com.github.aleksandermielczarek.observablecache2.CacheableCompletable;
import com.github.aleksandermielczarek.observablecache2.CacheableFlowable;
import com.github.aleksandermielczarek.observablecache2.CacheableMaybe;
import com.github.aleksandermielczarek.observablecache2.CacheableObservable;
import com.github.aleksandermielczarek.observablecache2.CacheableSingle;
import com.github.aleksandermielczarek.observablecache2.CompletableFromCache;
import com.github.aleksandermielczarek.observablecache2.FlowableFromCache;
import com.github.aleksandermielczarek.observablecache2.MaybeFromCache;
import com.github.aleksandermielczarek.observablecache2.ObservableFromCache;
import com.github.aleksandermielczarek.observablecache2.SingleFromCache;
import com.github.aleksandermielczarek.observablecache2.service.annotations.ObservableCacheService;
package com.github.aleksandermielczarek.observablecacheexample.service;



/**
 * Created by Aleksander Mielczarek on 10.02.2017.
 */

@ObservableCacheService
public interface Cached2Service {

    CacheableFlowable<String> flowable();

    FlowableFromCache<String> cachedFlowable();

    CacheableObservable<String> observable();

    ObservableFromCache<String> cachedObservable();

    CacheableSingle<String> single();

    SingleFromCache<String> cachedSingle();

    CacheableMaybe<String> maybe();