Noblocking getSync method
This commit is contained in:
parent
c496eba64e
commit
ed31b8db1a
|
|
@ -334,11 +334,16 @@ public abstract class BaseStorable<TKey, TObject, TStoreObject, TReturnObject> {
|
|||
*
|
||||
* @return Returns value;
|
||||
*/
|
||||
@Deprecated
|
||||
//deprecation: it should be used for debug only and in very rare cases.
|
||||
@Nullable
|
||||
public TReturnObject getSync() {
|
||||
return get().blockingGet();
|
||||
public TObject getSync() {
|
||||
final TStoreObject storeObject = store.getObject(storeObjectType, key);
|
||||
try {
|
||||
return converter.toObject(objectType, storeObjectType, storeObject);
|
||||
} 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);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -67,4 +67,14 @@ public interface Store<TKey, TStoreObject> {
|
|||
@NonNull
|
||||
Single<Optional<TStoreObject>> loadObject(@NonNull Type storeObjectType, @NonNull TKey key);
|
||||
|
||||
/**
|
||||
* Gets object from store by key.
|
||||
*
|
||||
* @param storeObjectType Type of object to store;
|
||||
* @param key Key related to object;
|
||||
* @return Object from store found by key;
|
||||
*/
|
||||
@Nullable
|
||||
TStoreObject getObject(@NonNull Type storeObjectType, @NonNull TKey key);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue