optional now looks java-like style
This commit is contained in:
parent
19f77a1bdd
commit
0fdc4c693e
|
|
@ -71,7 +71,7 @@ public abstract class BaseChangeable<TValue, TReturnValue> implements Serializab
|
|||
*/
|
||||
@Nullable
|
||||
public TValue get() {
|
||||
return valueSubject.getValue().getValue();
|
||||
return valueSubject.getValue().get();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class Changeable<T> extends BaseChangeable<T, T> {
|
|||
@Override
|
||||
//COMPATIBILITY NOTE: in RxJava2 it should be Observable<Optional<T>>
|
||||
public Observable<T> observe() {
|
||||
return observeOptionalValue().map(Optional::getValue);
|
||||
return observeOptionalValue().map(Optional::get);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -68,10 +68,10 @@ public class NonNullChangeable<T> extends BaseChangeable<T, T> {
|
|||
public Observable<T> observe() {
|
||||
return observeOptionalValue()
|
||||
.map(optional -> {
|
||||
if (optional.getValue() == null) {
|
||||
if (optional.get() == null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
return optional.getValue();
|
||||
return optional.get();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
|
|||
|
||||
@Nullable
|
||||
private Optional<TStoreObject> returnDefaultValueIfNull(@NonNull final Optional<TStoreObject> storeObject, @Nullable final TObject defaultValue) {
|
||||
if (storeObject.getValue() != null || defaultValue == null) {
|
||||
if (storeObject.get() != null || defaultValue == null) {
|
||||
return storeObject;
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
|
|||
final Observable<Optional<TObject>> result = storeValueObservable
|
||||
.map(storeObject -> {
|
||||
try {
|
||||
return new Optional<>(converter.toObject(objectType, storeObjectType, storeObject.getValue()));
|
||||
return new Optional<>(converter.toObject(objectType, storeObjectType, storeObject.get()));
|
||||
} catch (final Converter.ConversionException exception) {
|
||||
STORABLE_LC_GROUP.w(exception, "Exception while trying to converting value of '%s' from store %s by %s",
|
||||
key, storeObject, store, converter);
|
||||
|
|
@ -246,7 +246,7 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
|
|||
key, newValue, store, converter);
|
||||
return Completable.error(exception);
|
||||
}
|
||||
if (checkForEqualityBeforeSet && ObjectUtils.equals(newStoreValue, oldStoreValue.getValue())) {
|
||||
if (checkForEqualityBeforeSet && ObjectUtils.equals(newStoreValue, oldStoreValue.get())) {
|
||||
return Completable.complete();
|
||||
}
|
||||
return store.storeObject(storeObjectType, key, newStoreValue)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class Migration<TKey> {
|
|||
@NonNull
|
||||
private Single<Long> loadCurrentVersion(@NonNull final TKey key) {
|
||||
return versionsStore.loadObject(Long.class, key)
|
||||
.map(version -> version.getValue() != null ? version.getValue() : DEFAULT_VERSION)
|
||||
.map(version -> version.get() != null ? version.get() : DEFAULT_VERSION)
|
||||
.onErrorResumeNext(throwable
|
||||
-> Single.error(new MigrationException(String.format("Can't get version of '%s' from %s", key, versionsStore), throwable)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class Storable<TKey, TObject, TStoreObject> extends BaseStorable<TKey, TO
|
|||
@NonNull
|
||||
@Override
|
||||
public Observable<TObject> observe() {
|
||||
return observeOptionalValue().map(Optional::getValue);
|
||||
return observeOptionalValue().map(Optional::get);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -51,10 +51,10 @@ public class NonNullStorable<TKey, TObject, TStoreObject> extends BaseStorable<T
|
|||
public Observable<TObject> observe() {
|
||||
return observeOptionalValue()
|
||||
.map(optional -> {
|
||||
if (optional.getValue() == null) {
|
||||
if (optional.get() == null) {
|
||||
throw new ShouldNotHappenException();
|
||||
}
|
||||
return optional.getValue();
|
||||
return optional.get();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class Optional<T> implements Serializable {
|
|||
* @return Holding object.
|
||||
*/
|
||||
@Nullable
|
||||
public T getValue() {
|
||||
public T get() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue