@Override public long count(Class<?> type) { Assert.notNull(type, "Type for count must not be null!"); return adapter.count(resolveKeySpace(type)); }
@Override public long count(Class<?> type) { Assert.notNull(type, "Type for count must not be null!"); return adapter.count(resolveKeySpace(type)); }
@Override public long count(Class<?> type) { Assert.notNull(type, "Type for count must not be null!"); return adapter.count(resolveKeySpace(type)); }
@Override public <T> Iterable<T> findAll(Class<T> type) { Assert.notNull(type, "Type to fetch must not be null!"); return executeRequired(adapter -> { Iterable<?> values = adapter.getAllOf(resolveKeySpace(type)); ArrayList<T> filtered = new ArrayList<>(); for (Object candidate : values) { if (typeCheck(type, candidate)) { filtered.add(type.cast(candidate)); } } return filtered; }); }
@Override public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type) { return executeRequired((KeyValueCallback<Iterable<T>>) adapter -> { Iterable<?> result = adapter.find(query, resolveKeySpace(type), type); List<T> filtered = new ArrayList<>(); for (Object candidate : result) { if (typeCheck(type, candidate)) { filtered.add(type.cast(candidate)); } } return filtered; }); }
@Override public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type) { return executeRequired((KeyValueCallback<Iterable<T>>) adapter -> { Iterable<?> result = adapter.find(query, resolveKeySpace(type), type); List<T> filtered = new ArrayList<>(); for (Object candidate : result) { if (typeCheck(type, candidate)) { filtered.add(type.cast(candidate)); } } return filtered; }); }
@Override public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type) { return executeRequired((KeyValueCallback<Iterable<T>>) adapter -> { Iterable<?> result = adapter.find(query, resolveKeySpace(type), type); List<T> filtered = new ArrayList<>(); for (Object candidate : result) { if (typeCheck(type, candidate)) { filtered.add(type.cast(candidate)); } } return filtered; }); }
@Override public <T> Iterable<T> findAll(Class<T> type) { Assert.notNull(type, "Type to fetch must not be null!"); return executeRequired(adapter -> { Iterable<?> values = adapter.getAllOf(resolveKeySpace(type)); ArrayList<T> filtered = new ArrayList<>(); for (Object candidate : values) { if (typeCheck(type, candidate)) { filtered.add(type.cast(candidate)); } } return filtered; }); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
@Override public long count(KeyValueQuery<?> query, Class<?> type) { return executeRequired(adapter -> adapter.count(query, resolveKeySpace(type))); }
@Override public <T> T update(Object id, T objectToUpdate) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(objectToUpdate, "Object to be updated must not be null!"); String keyspace = resolveKeySpace(objectToUpdate.getClass()); potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate)); Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace)); potentiallyPublishEvent( KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing)); return objectToUpdate; }
@Override public <T> T update(Object id, T objectToUpdate) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(objectToUpdate, "Object to be updated must not be null!"); String keyspace = resolveKeySpace(objectToUpdate.getClass()); potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate)); Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace)); potentiallyPublishEvent( KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing)); return objectToUpdate; }
@Override public <T> T update(Object id, T objectToUpdate) { Assert.notNull(id, "Id for object to be inserted must not be null!"); Assert.notNull(objectToUpdate, "Object to be updated must not be null!"); String keyspace = resolveKeySpace(objectToUpdate.getClass()); potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate)); Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace)); potentiallyPublishEvent( KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing)); return objectToUpdate; }
@Override public <T> T delete(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be deleted must not be null!"); Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type)); T result = execute(adapter -> adapter.delete(id, keyspace, type)); potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result)); return result; }
@Override public <T> T delete(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be deleted must not be null!"); Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type)); T result = execute(adapter -> adapter.delete(id, keyspace, type)); potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result)); return result; }
@Override public <T> T delete(Object id, Class<T> type) { Assert.notNull(id, "Id for object to be deleted must not be null!"); Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type)); T result = execute(adapter -> adapter.delete(id, keyspace, type)); potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result)); return result; }
@Override public void delete(Class<?> type) { Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type)); execute((KeyValueCallback<Void>) adapter -> { adapter.deleteAllOf(keyspace); return null; }); potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type)); }
@Override public void delete(Class<?> type) { Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type)); execute((KeyValueCallback<Void>) adapter -> { adapter.deleteAllOf(keyspace); return null; }); potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type)); }
@Override public void delete(Class<?> type) { Assert.notNull(type, "Type to delete must not be null!"); String keyspace = resolveKeySpace(type); potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type)); execute((KeyValueCallback<Void>) adapter -> { adapter.deleteAllOf(keyspace); return null; }); potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type)); }