From ea11307d46d8f6f27137926d0800ef820795fe24 Mon Sep 17 00:00:00 2001 From: Aleksander Mielczarek Date: Tue, 18 Jul 2017 13:36:34 +0200 Subject: [PATCH] Add static factory methods --- .../observablecache/CompletableFromCache.java | 8 ++++++++ .../observablecache/ObservableFromCache.java | 8 ++++++++ .../observablecache/SingleFromCache.java | 8 ++++++++ .../observablecache2/CompletableFromCache.java | 9 +++++++++ .../observablecache2/FlowableFromCache.java | 8 ++++++++ .../observablecache2/MaybeFromCache.java | 8 ++++++++ .../observablecache2/ObservableFromCache.java | 8 ++++++++ .../observablecache2/SingleFromCache.java | 8 ++++++++ 8 files changed, 65 insertions(+) diff --git a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/CompletableFromCache.java b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/CompletableFromCache.java index 4e632f7..ad7d9ec 100644 --- a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/CompletableFromCache.java +++ b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/CompletableFromCache.java @@ -15,4 +15,12 @@ public final class CompletableFromCache extends ValueFromCache { super(valueFromCache); } + public static CompletableFromCache empty() { + return new CompletableFromCache(null); + } + + public static CompletableFromCache of(@Nullable Completable valueFromCache) { + return new CompletableFromCache(valueFromCache); + } + } diff --git a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/ObservableFromCache.java b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/ObservableFromCache.java index 5987957..8e6a156 100644 --- a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/ObservableFromCache.java +++ b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/ObservableFromCache.java @@ -15,4 +15,12 @@ public final class ObservableFromCache extends ValueFromCache> super(valueFromCache); } + public static ObservableFromCache empty() { + return new ObservableFromCache<>(null); + } + + public static ObservableFromCache of(@Nullable Observable valueFromCache) { + return new ObservableFromCache<>(valueFromCache); + } + } diff --git a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/SingleFromCache.java b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/SingleFromCache.java index 8a3733c..596ede0 100644 --- a/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/SingleFromCache.java +++ b/observable-cache-1/src/main/java/com/github/aleksandermielczarek/observablecache/SingleFromCache.java @@ -15,4 +15,12 @@ public final class SingleFromCache extends ValueFromCache> { super(valueFromCache); } + public static SingleFromCache empty() { + return new SingleFromCache<>(null); + } + + public static SingleFromCache of(@Nullable Single valueFromCache) { + return new SingleFromCache<>(valueFromCache); + } + } diff --git a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/CompletableFromCache.java b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/CompletableFromCache.java index cd5a9d5..352bb1b 100644 --- a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/CompletableFromCache.java +++ b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/CompletableFromCache.java @@ -15,4 +15,13 @@ public final class CompletableFromCache extends ValueFromCache { CompletableFromCache(@Nullable Completable valueFromCache) { super(valueFromCache); } + + public static CompletableFromCache empty() { + return new CompletableFromCache(null); + } + + public static CompletableFromCache of(@Nullable Completable valueFromCache) { + return new CompletableFromCache(valueFromCache); + } + } diff --git a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/FlowableFromCache.java b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/FlowableFromCache.java index 031ad61..d5a2f0d 100644 --- a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/FlowableFromCache.java +++ b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/FlowableFromCache.java @@ -16,4 +16,12 @@ public final class FlowableFromCache extends ValueFromCache> { super(valueFromCache); } + public static FlowableFromCache empty() { + return new FlowableFromCache<>(null); + } + + public static FlowableFromCache of(@Nullable Flowable valueFromCache) { + return new FlowableFromCache<>(valueFromCache); + } + } diff --git a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/MaybeFromCache.java b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/MaybeFromCache.java index 2257b4d..97afa94 100644 --- a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/MaybeFromCache.java +++ b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/MaybeFromCache.java @@ -16,4 +16,12 @@ public final class MaybeFromCache extends ValueFromCache> { super(valueFromCache); } + public static MaybeFromCache empty() { + return new MaybeFromCache<>(null); + } + + public static MaybeFromCache of(@Nullable Maybe valueFromCache) { + return new MaybeFromCache<>(valueFromCache); + } + } diff --git a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/ObservableFromCache.java b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/ObservableFromCache.java index 2fb3c53..e3304cc 100644 --- a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/ObservableFromCache.java +++ b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/ObservableFromCache.java @@ -16,4 +16,12 @@ public final class ObservableFromCache extends ValueFromCache> super(valueFromCache); } + public static ObservableFromCache empty() { + return new ObservableFromCache<>(null); + } + + public static ObservableFromCache of(@Nullable Observable valueFromCache) { + return new ObservableFromCache<>(valueFromCache); + } + } diff --git a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/SingleFromCache.java b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/SingleFromCache.java index e801dd1..cb7cf4b 100644 --- a/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/SingleFromCache.java +++ b/observable-cache-2/src/main/java/com/github/aleksandermielczarek/observablecache2/SingleFromCache.java @@ -16,4 +16,12 @@ public final class SingleFromCache extends ValueFromCache> { super(valueFromCache); } + public static SingleFromCache empty() { + return new SingleFromCache<>(null); + } + + public static SingleFromCache of(@Nullable Single valueFromCache) { + return new SingleFromCache<>(valueFromCache); + } + }