This commit is contained in:
Denis Karmyshakov 2018-01-07 21:26:23 +00:00 committed by GitHub
commit 9731f9bbf0
2 changed files with 19 additions and 4 deletions

View File

@ -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;
}
}
/**

View File

@ -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);
}