Skip to content

Commit

Permalink
Remove unnecessary methods
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderMielczarek committed Oct 30, 2016
1 parent fc1cbdf commit d8f562b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Napkin.provideComponent(this, AppComponent.class).inject(this);
Napkin.<AppComponent>provideComponent(this).inject(this);
mainViewModel.restoreState(state);
ActivityMainBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
binding.setViewModel(mainViewModel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ public void testCompletable(Completable completable) {
}

public void restoreObservables() {
observableCache.getObservable(OBSERVABLE_CACHE_KEY_OBSERVABLE, String.class)
observableCache.<String>getObservable(OBSERVABLE_CACHE_KEY_OBSERVABLE)
.ifPresent(this::testObservable)
.thanGetSingle(OBSERVABLE_CACHE_KEY_SINGLE, String.class)
.<String>thanGetSingle(OBSERVABLE_CACHE_KEY_SINGLE)
.ifPresent(this::testSingle)
.thanGetCompletable(OBSERVABLE_CACHE_KEY_COMPLETABLE)
.ifPresent(this::testCompletable)
.thanGetObservable(OBSERVABLE_CACHE_KEY_OBSERVABLE_ERROR, String.class)
.<String>thanGetObservable(OBSERVABLE_CACHE_KEY_OBSERVABLE_ERROR)
.ifPresent(this::testObservable)
.thanGetSingle(OBSERVABLE_CACHE_KEY_SINGLE_ERROR, String.class)
.<String>thanGetSingle(OBSERVABLE_CACHE_KEY_SINGLE_ERROR)
.ifPresent(this::testSingle)
.thanGetCompletable(OBSERVABLE_CACHE_KEY_COMPLETABLE_ERROR)
.ifPresent(this::testCompletable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Created by Aleksander Mielczarek on 30.10.2016.
*/

public class LruObservableCache extends ObservableCache {
public final class LruObservableCache extends ObservableCache {

public static final int DEFAULT_CACHE_SIZE = 16;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public <T> ObservableFromCache<T> getObservable(String key) {
return new ObservableFromCache<>(observableFromCache, this);
}

public <T> ObservableFromCache<T> getObservable(String key, Class<T> observableClass) {
return getObservable(key);
}

public <T> SingleFromCache<T> getSingle(String key) {
Observable<T> observableFromCache = getFromCache(key);
if (observableFromCache != null) {
Expand All @@ -86,10 +82,6 @@ public <T> SingleFromCache<T> getSingle(String key) {
return new SingleFromCache<>(null, this);
}

public <T> SingleFromCache<T> getSingle(String key, Class<T> singleClass) {
return getSingle(key);
}

public CompletableFromCache getCompletable(String key) {
Observable<?> observableFromCache = getFromCache(key);
if (observableFromCache != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ public boolean isPresent() {
return valueFromCache != null;
}

@Nullable
public T get() {
return valueFromCache;
}

public ValueFromCache<T, S, U> ifPresent(S valueInCacheAction) {
if (isPresent()) {
valueInCacheAction.action(valueFromCache);
Expand All @@ -42,27 +47,13 @@ public <V> ObservableFromCache<V> orElseGetObservable(String key) {
return new ObservableFromCache<>(null, observableCache);
}

public <V> ObservableFromCache<V> orElseGetObservable(String key, Class<V> observableClass) {
if (!isPresent()) {
return observableCache.getObservable(key, observableClass);
}
return new ObservableFromCache<>(null, observableCache);
}

public <V> SingleFromCache<V> orElseGetSingle(String key) {
if (!isPresent()) {
return observableCache.getSingle(key);
}
return new SingleFromCache<>(null, observableCache);
}

public <V> SingleFromCache<V> orElseGetSingle(String key, Class<V> singleClass) {
if (!isPresent()) {
return observableCache.getSingle(key, singleClass);
}
return new SingleFromCache<>(null, observableCache);
}

public CompletableFromCache orElseGetCompletable(String key) {
if (!isPresent()) {
return observableCache.getCompletable(key);
Expand All @@ -74,18 +65,10 @@ public <V> ObservableFromCache<V> thanGetObservable(String key) {
return observableCache.getObservable(key);
}

public <V> ObservableFromCache<V> thanGetObservable(String key, Class<V> observableClass) {
return observableCache.getObservable(key, observableClass);
}

public <V> SingleFromCache<V> thanGetSingle(String key) {
return observableCache.getSingle(key);
}

public <V> SingleFromCache<V> thanGetSingle(String key, Class<V> singleClass) {
return observableCache.getSingle(key, singleClass);
}

public CompletableFromCache thanGetCompletable(String key) {
return observableCache.getCompletable(key);
}
Expand Down

0 comments on commit d8f562b

Please sign in to comment.