@Override public <T> Optional<T> findById(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(type, "Type to fetch must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type)); T result = execute(adapter -> { Object value = adapter.get(id, keyspace, type); if (value == null || typeCheck(type, value)) { return type.cast(value); } return null; }); potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result)); return Optional.ofNullable(result); }
@Override public <T> Optional<T> findById(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(type, "Type to fetch must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type)); T result = execute(adapter -> { Object value = adapter.get(id, keyspace, type); if (value == null || typeCheck(type, value)) { return type.cast(value); } return null; }); potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result)); return Optional.ofNullable(result); }
@Override public <T> Optional<T> findById(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(type, "Type to fetch must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type)); T result = execute(adapter -> { Object value = adapter.get(id, keyspace, type); if (value == null || typeCheck(type, value)) { return type.cast(value); } return null; }); potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result)); return Optional.ofNullable(result); }