DATAKV-187 - Polishing.

Remove Serializable ID constraints from factory beans. Replace casts with type.cast(…). Convert anonymous inner classes to lambdas. Remove unused code and casts. Simplify test entities by removing Serializable and using lombok. Letter casing, formatting, Javadoc.

Original pull request: #25.
This commit is contained in:
Mark Paluch
2017-07-21 14:18:33 +02:00
parent d6ee87ace5
commit 14da42ff15
16 changed files with 200 additions and 492 deletions

View File

@@ -24,6 +24,7 @@ import org.springframework.data.keyvalue.core.query.KeyValueQuery;
* {@literal count} execution to.
*
* @author Christoph Strobl
* @author Mark Paluch
*/
public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
@@ -43,7 +44,7 @@ public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
*/
protected AbstractKeyValueAdapter(QueryEngine<? extends KeyValueAdapter, ?, ?> engine) {
this.engine = engine != null ? engine : new SpelQueryEngine<>();
this.engine = engine != null ? engine : new SpelQueryEngine();
this.engine.registerAdapter(this);
}
@@ -62,7 +63,7 @@ public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
*/
@Override
public <T> T get(Object id, String keyspace, Class<T> type) {
return (T) get(id, keyspace);
return type.cast(get(id, keyspace));
}
/*
@@ -71,7 +72,7 @@ public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
*/
@Override
public <T> T delete(Object id, String keyspace, Class<T> type) {
return (T) delete(id, keyspace);
return type.cast(delete(id, keyspace));
}
/*

View File

@@ -25,14 +25,14 @@ import org.springframework.data.mapping.context.MappingContext;
/**
* Interface that specifies a basic set of key/value operations. Implemented by {@link KeyValueTemplate}.
*
*
* @author Christoph Strobl
*/
public interface KeyValueOperations extends DisposableBean {
/**
* Add given object. Object needs to have id property to which a generated value will be assigned.
*
*
* @param objectToInsert
* @return
*/
@@ -40,7 +40,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Add object with given id.
*
*
* @param id must not be {@literal null}.
* @param objectToInsert must not be {@literal null}.
*/
@@ -49,7 +49,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get all elements of given type. Respects {@link KeySpace} if present and therefore returns all elements that can be
* assigned to requested type.
*
*
* @param type must not be {@literal null}.
* @return empty iterable if no elements found.
*/
@@ -58,7 +58,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get all elements ordered by sort. Respects {@link KeySpace} if present and therefore returns all elements that can
* be assigned to requested type.
*
*
* @param sort must not be {@literal null}.
* @param type must not be {@literal null}.
* @return
@@ -68,16 +68,16 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get element of given type with given id. Respects {@link KeySpace} if present and therefore returns all elements
* that can be assigned to requested type.
*
*
* @param id must not be {@literal null}.
* @param type must not be {@literal null}.
* @return null if not found.
* @return {@link Optional#empty()} if not found.
*/
<T> Optional<T> findById(Object id, Class<T> type);
/**
* Execute operation against underlying store.
*
*
* @param action must not be {@literal null}.
* @return
*/
@@ -86,7 +86,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get all elements matching the given query. <br />
* Respects {@link KeySpace} if present and therefore returns all elements that can be assigned to requested type..
*
*
* @param query must not be {@literal null}.
* @param type must not be {@literal null}.
* @return empty iterable if no match found.
@@ -96,7 +96,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get all elements in given range. Respects {@link KeySpace} if present and therefore returns all elements that can
* be assigned to requested type.
*
*
* @param offset
* @param rows
* @param type must not be {@literal null}.
@@ -107,7 +107,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Get all elements in given range ordered by sort. Respects {@link KeySpace} if present and therefore returns all
* elements that can be assigned to requested type.
*
*
* @param offset
* @param rows
* @param sort
@@ -130,7 +130,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Remove all elements of type. Respects {@link KeySpace} if present and therefore removes all elements that can be
* assigned to requested type.
*
*
* @param type must not be {@literal null}.
*/
void delete(Class<?> type);
@@ -143,7 +143,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Delete item of type with given id.
*
*
* @param id must not be {@literal null}.
* @param type must not be {@literal null}.
* @return the deleted item or {@literal null} if no match found.
@@ -153,7 +153,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Total number of elements with given type available. Respects {@link KeySpace} if present and therefore counts all
* elements that can be assigned to requested type.
*
*
* @param type must not be {@literal null}.
* @return
*/
@@ -162,7 +162,7 @@ public interface KeyValueOperations extends DisposableBean {
/**
* Total number of elements matching given query. Respects {@link KeySpace} if present and therefore counts all
* elements that can be assigned to requested type.
*
*
* @param query
* @param type
* @return

View File

@@ -67,7 +67,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @param adapter must not be {@literal null}.
*/
public KeyValueTemplate(KeyValueAdapter adapter) {
this(adapter, new KeyValueMappingContext());
this(adapter, new KeyValueMappingContext<>());
}
/**
@@ -149,28 +149,24 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#insert(java.lang.Object, java.lang.Object)
*/
@Override
public void insert(final Object id, final Object objectToInsert) {
public void insert(Object id, Object objectToInsert) {
Assert.notNull(id, "Id for object to be inserted must not be null!");
Assert.notNull(objectToInsert, "Object to be inserted must not be null!");
final String keyspace = resolveKeySpace(objectToInsert.getClass());
String keyspace = resolveKeySpace(objectToInsert.getClass());
potentiallyPublishEvent(KeyValueEvent.beforeInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
execute(new KeyValueCallback<Void>() {
execute((KeyValueCallback<Void>) adapter -> {
@Override
public Void doInKeyValue(KeyValueAdapter adapter) {
if (adapter.contains(id, keyspace)) {
throw new DuplicateKeyException(
String.format("Cannot insert existing object with id %s!. Please use update.", id));
}
adapter.put(id, objectToInsert, keyspace);
return null;
if (adapter.contains(id, keyspace)) {
throw new DuplicateKeyException(
String.format("Cannot insert existing object with id %s!. Please use update.", id));
}
adapter.put(id, objectToInsert, keyspace);
return null;
});
potentiallyPublishEvent(KeyValueEvent.afterInsert(id, keyspace, objectToInsert.getClass(), objectToInsert));
@@ -199,22 +195,16 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#update(java.lang.Object, java.lang.Object)
*/
@Override
public void update(final Object id, final Object objectToUpdate) {
public void update(Object id, Object 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!");
final String keyspace = resolveKeySpace(objectToUpdate.getClass());
String keyspace = resolveKeySpace(objectToUpdate.getClass());
potentiallyPublishEvent(KeyValueEvent.beforeUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate));
Object existing = execute(new KeyValueCallback<Object>() {
@Override
public Object doInKeyValue(KeyValueAdapter adapter) {
return adapter.put(id, objectToUpdate, keyspace);
}
});
Object existing = execute(adapter -> adapter.put(id, objectToUpdate, keyspace));
potentiallyPublishEvent(
KeyValueEvent.afterUpdate(id, keyspace, objectToUpdate.getClass(), objectToUpdate, existing));
@@ -225,7 +215,7 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#findAllOf(java.lang.Class)
*/
@Override
public <T> Iterable<T> findAll(final Class<T> type) {
public <T> Iterable<T> findAll(Class<T> type) {
Assert.notNull(type, "Type to fetch must not be null!");
@@ -258,29 +248,24 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#findById(java.lang.Object, java.lang.Class)
*/
@Override
public <T> Optional<T> findById(final Object id, final Class<T> type) {
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!");
final String keyspace = resolveKeySpace(type);
String keyspace = resolveKeySpace(type);
potentiallyPublishEvent(KeyValueEvent.beforeGet(id, keyspace, type));
T result = execute(new KeyValueCallback<T>() {
T result = execute(adapter -> {
@SuppressWarnings("unchecked")
@Override
public T doInKeyValue(KeyValueAdapter adapter) {
Object value = adapter.get(id, keyspace, type);
Object result = adapter.get(id, keyspace, type);
if (result == null || typeCheck(type, result)) {
return (T) result;
}
return null;
if (value == null || typeCheck(type, value)) {
return type.cast(value);
}
return null;
});
potentiallyPublishEvent(KeyValueEvent.afterGet(id, keyspace, type, result));
@@ -293,22 +278,18 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#delete(java.lang.Class)
*/
@Override
public void delete(final Class<?> type) {
public void delete(Class<?> type) {
Assert.notNull(type, "Type to delete must not be null!");
final String keyspace = resolveKeySpace(type);
String keyspace = resolveKeySpace(type);
potentiallyPublishEvent(KeyValueEvent.beforeDropKeySpace(keyspace, type));
execute(new KeyValueCallback<Void>() {
execute((KeyValueCallback<Void>) adapter -> {
@Override
public Void doInKeyValue(KeyValueAdapter adapter) {
adapter.deleteAllOf(keyspace);
return null;
}
adapter.deleteAllOf(keyspace);
return null;
});
potentiallyPublishEvent(KeyValueEvent.afterDropKeySpace(keyspace, type));
@@ -333,22 +314,16 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#delete(java.lang.Object, java.lang.Class)
*/
@Override
public <T> T delete(final Object id, final Class<T> type) {
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!");
final String keyspace = resolveKeySpace(type);
String keyspace = resolveKeySpace(type);
potentiallyPublishEvent(KeyValueEvent.beforeDelete(id, keyspace, type));
T result = execute(new KeyValueCallback<T>() {
@Override
public T doInKeyValue(KeyValueAdapter adapter) {
return (T) adapter.delete(id, keyspace, type);
}
});
T result = execute(adapter -> (T) adapter.delete(id, keyspace, type));
potentiallyPublishEvent(KeyValueEvent.afterDelete(id, keyspace, type, result));
@@ -387,29 +362,24 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#find(org.springframework.data.keyvalue.core.query.KeyValueQuery, java.lang.Class)
*/
@Override
public <T> Iterable<T> find(final KeyValueQuery<?> query, final Class<T> type) {
public <T> Iterable<T> find(KeyValueQuery<?> query, Class<T> type) {
return execute(new KeyValueCallback<Iterable<T>>() {
return execute((KeyValueCallback<Iterable<T>>) adapter -> {
@SuppressWarnings("unchecked")
@Override
public Iterable<T> doInKeyValue(KeyValueAdapter adapter) {
Iterable<?> result = adapter.find(query, resolveKeySpace(type), type);
if (result == null) {
return Collections.emptySet();
}
List<T> filtered = new ArrayList<>();
for (Object candidate : result) {
if (typeCheck(type, candidate)) {
filtered.add((T) candidate);
}
}
return filtered;
Iterable<?> result = adapter.find(query, resolveKeySpace(type), type);
if (result == null) {
return Collections.emptySet();
}
List<T> filtered = new ArrayList<>();
for (Object candidate : result) {
if (typeCheck(type, candidate)) {
filtered.add(type.cast(candidate));
}
}
return filtered;
});
}
@@ -448,15 +418,9 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
* @see org.springframework.data.keyvalue.core.KeyValueOperations#count(org.springframework.data.keyvalue.core.query.KeyValueQuery, java.lang.Class)
*/
@Override
public long count(final KeyValueQuery<?> query, final Class<?> type) {
public long count(KeyValueQuery<?> query, Class<?> type) {
return execute(new KeyValueCallback<Long>() {
@Override
public Long doInKeyValue(KeyValueAdapter adapter) {
return adapter.count(query, resolveKeySpace(type));
}
});
return execute(adapter -> adapter.count(query, resolveKeySpace(type)));
}
/*
@@ -500,6 +464,6 @@ public class KeyValueTemplate implements KeyValueOperations, ApplicationEventPub
}
private static boolean typeCheck(Class<?> requiredType, Object candidate) {
return candidate == null ? true : ClassUtils.isAssignable(requiredType, candidate.getClass());
return candidate == null || ClassUtils.isAssignable(requiredType, candidate.getClass());
}
}

View File

@@ -17,7 +17,6 @@ package org.springframework.data.keyvalue.core;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -32,9 +31,10 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
*
* @author Christoph Strobl
* @author Oliver Gierke
* @author Mark Paluch
* @param <T>
*/
class SpelQueryEngine<T extends KeyValueAdapter> extends QueryEngine<KeyValueAdapter, SpelCriteria, Comparator<?>> {
class SpelQueryEngine extends QueryEngine<KeyValueAdapter, SpelCriteria, Comparator<?>> {
private static final SpelExpressionParser PARSER = new SpelExpressionParser();
@@ -63,13 +63,13 @@ class SpelQueryEngine<T extends KeyValueAdapter> extends QueryEngine<KeyValueAda
return filterMatchingRange(getAdapter().getAllOf(keyspace), criteria, -1, -1).size();
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@SuppressWarnings("unchecked")
private List<?> sortAndFilterMatchingRange(Iterable<?> source, SpelCriteria criteria, Comparator sort, long offset,
int rows) {
List<?> tmp = IterableConverter.toList(source);
if (sort != null) {
Collections.sort(tmp, sort);
tmp.sort(sort);
}
return filterMatchingRange(tmp, criteria, offset, rows);

View File

@@ -54,126 +54,126 @@ public class KeyValueEvent<T> extends ApplicationEvent {
* Create new {@link BeforeGetEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @return
*/
public static <T> BeforeGetEvent<T> beforeGet(Object id, String keySpace, Class<T> type) {
return new BeforeGetEvent<>(id, keySpace, type);
public static <T> BeforeGetEvent<T> beforeGet(Object id, String keyspace, Class<T> type) {
return new BeforeGetEvent<>(id, keyspace, type);
}
/**
* Create new {@link AfterGetEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param value
* @return
*/
public static <T> AfterGetEvent<T> afterGet(Object id, String keySpace, Class<T> type, T value) {
return new AfterGetEvent<>(id, keySpace, type, value);
public static <T> AfterGetEvent<T> afterGet(Object id, String keyspace, Class<T> type, T value) {
return new AfterGetEvent<>(id, keyspace, type, value);
}
/**
* Create new {@link BeforeInsertEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param value
* @return
*/
public static <T> BeforeInsertEvent<T> beforeInsert(Object id, String keySpace, Class<? extends T> type, T value) {
return new BeforeInsertEvent<>(id, keySpace, type, value);
public static <T> BeforeInsertEvent<T> beforeInsert(Object id, String keyspace, Class<? extends T> type, T value) {
return new BeforeInsertEvent<>(id, keyspace, type, value);
}
/**
* Create new {@link AfterInsertEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param value
* @return
*/
public static <T> AfterInsertEvent<T> afterInsert(Object id, String keySpace, Class<? extends T> type, T value) {
return new AfterInsertEvent<>(id, keySpace, type, value);
public static <T> AfterInsertEvent<T> afterInsert(Object id, String keyspace, Class<? extends T> type, T value) {
return new AfterInsertEvent<>(id, keyspace, type, value);
}
/**
* Create new {@link BeforeUpdateEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param value
* @return
*/
public static <T> BeforeUpdateEvent<T> beforeUpdate(Object id, String keySpace, Class<? extends T> type, T value) {
return new BeforeUpdateEvent<>(id, keySpace, type, value);
public static <T> BeforeUpdateEvent<T> beforeUpdate(Object id, String keyspace, Class<? extends T> type, T value) {
return new BeforeUpdateEvent<>(id, keyspace, type, value);
}
/**
* Create new {@link AfterUpdateEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param actualValue
* @param previousValue
* @return
*/
public static <T> AfterUpdateEvent<T> afterUpdate(Object id, String keySpace, Class<? extends T> type, T actualValue,
public static <T> AfterUpdateEvent<T> afterUpdate(Object id, String keyspace, Class<? extends T> type, T actualValue,
Object previousValue) {
return new AfterUpdateEvent<>(id, keySpace, type, actualValue, previousValue);
return new AfterUpdateEvent<>(id, keyspace, type, actualValue, previousValue);
}
/**
* Create new {@link BeforeDropKeySpaceEvent}.
*
* @param keySpace
* @param keyspace
* @param type
* @return
*/
public static <T> BeforeDropKeySpaceEvent<T> beforeDropKeySpace(String keySpace, Class<? extends T> type) {
return new BeforeDropKeySpaceEvent<>(keySpace, type);
public static <T> BeforeDropKeySpaceEvent<T> beforeDropKeySpace(String keyspace, Class<? extends T> type) {
return new BeforeDropKeySpaceEvent<>(keyspace, type);
}
/**
* Create new {@link AfterDropKeySpaceEvent}.
*
* @param keySpace
* @param keyspace
* @param type
* @return
*/
public static <T> AfterDropKeySpaceEvent<T> afterDropKeySpace(String keySpace, Class<? extends T> type) {
return new AfterDropKeySpaceEvent<>(keySpace, type);
public static <T> AfterDropKeySpaceEvent<T> afterDropKeySpace(String keyspace, Class<? extends T> type) {
return new AfterDropKeySpaceEvent<>(keyspace, type);
}
/**
* Create new {@link BeforeDeleteEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @return
*/
public static <T> BeforeDeleteEvent<T> beforeDelete(Object id, String keySpace, Class<? extends T> type) {
return new BeforeDeleteEvent<>(id, keySpace, type);
public static <T> BeforeDeleteEvent<T> beforeDelete(Object id, String keyspace, Class<? extends T> type) {
return new BeforeDeleteEvent<>(id, keyspace, type);
}
/**
* Create new {@link AfterDeleteEvent}.
*
* @param id
* @param keySpace
* @param keyspace
* @param type
* @param value
* @return
*/
public static <T> AfterDeleteEvent<T> afterDelete(Object id, String keySpace, Class<? extends T> type, T value) {
return new AfterDeleteEvent<>(id, keySpace, type, value);
public static <T> AfterDeleteEvent<T> afterDelete(Object id, String keyspace, Class<? extends T> type, T value) {
return new AfterDeleteEvent<>(id, keyspace, type, value);
}
/**
@@ -186,9 +186,9 @@ public class KeyValueEvent<T> extends ApplicationEvent {
private Object key;
private Class<? extends T> type;
protected KeyBasedEvent(Object key, String keySpace, Class<? extends T> type) {
protected KeyBasedEvent(Object key, String keyspace, Class<? extends T> type) {
super(type, keySpace);
super(type, keyspace);
this.key = key;
this.type = type;
}
@@ -225,8 +225,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
private final T payload;
public KeyBasedEventWithPayload(Object key, String keySpace, Class<? extends T> type, T payload) {
super(key, keySpace, type);
public KeyBasedEventWithPayload(Object key, String keyspace, Class<? extends T> type, T payload) {
super(key, keyspace, type);
this.payload = payload;
}
@@ -249,8 +249,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class BeforeGetEvent<T> extends KeyBasedEvent<T> {
protected BeforeGetEvent(Object key, String keySpace, Class<T> type) {
super(key, keySpace, type);
protected BeforeGetEvent(Object key, String keyspace, Class<T> type) {
super(key, keyspace, type);
}
}
@@ -279,8 +279,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class BeforeInsertEvent<T> extends KeyBasedEventWithPayload<T> {
public BeforeInsertEvent(Object key, String keySpace, Class<? extends T> type, T payload) {
super(key, keySpace, type, payload);
public BeforeInsertEvent(Object key, String keyspace, Class<? extends T> type, T payload) {
super(key, keyspace, type, payload);
}
}
@@ -294,8 +294,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class AfterInsertEvent<T> extends KeyBasedEventWithPayload<T> {
public AfterInsertEvent(Object key, String keySpace, Class<? extends T> type, T payload) {
super(key, keySpace, type, payload);
public AfterInsertEvent(Object key, String keyspace, Class<? extends T> type, T payload) {
super(key, keyspace, type, payload);
}
}
@@ -308,8 +308,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class BeforeUpdateEvent<T> extends KeyBasedEventWithPayload<T> {
public BeforeUpdateEvent(Object key, String keySpace, Class<? extends T> type, T payload) {
super(key, keySpace, type, payload);
public BeforeUpdateEvent(Object key, String keyspace, Class<? extends T> type, T payload) {
super(key, keyspace, type, payload);
}
}
@@ -324,8 +324,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
private final Object existing;
public AfterUpdateEvent(Object key, String keySpace, Class<? extends T> type, T payload, Object existing) {
super(key, keySpace, type, payload);
public AfterUpdateEvent(Object key, String keyspace, Class<? extends T> type, T payload, Object existing) {
super(key, keyspace, type, payload);
this.existing = existing;
}
@@ -357,8 +357,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class BeforeDeleteEvent<T> extends KeyBasedEvent<T> {
public BeforeDeleteEvent(Object key, String keySpace, Class<? extends T> type) {
super(key, keySpace, type);
public BeforeDeleteEvent(Object key, String keyspace, Class<? extends T> type) {
super(key, keyspace, type);
}
}
@@ -371,13 +371,13 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class AfterDeleteEvent<T> extends KeyBasedEventWithPayload<T> {
public AfterDeleteEvent(Object key, String keySpace, Class<? extends T> type, T payload) {
super(key, keySpace, type, payload);
public AfterDeleteEvent(Object key, String keyspace, Class<? extends T> type, T payload) {
super(key, keyspace, type, payload);
}
}
/**
* {@link KeyValueEvent} before removing all elements in a given {@literal keySpace}.
* {@link KeyValueEvent} before removing all elements in a given {@literal keyspace}.
*
* @author Christoph Strobl
* @param <T>
@@ -385,8 +385,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class BeforeDropKeySpaceEvent<T> extends KeyValueEvent<T> {
public BeforeDropKeySpaceEvent(String keySpace, Class<? extends T> type) {
super(type, keySpace);
public BeforeDropKeySpaceEvent(String keyspace, Class<? extends T> type) {
super(type, keyspace);
}
@Override
@@ -398,7 +398,7 @@ public class KeyValueEvent<T> extends ApplicationEvent {
}
/**
* {@link KeyValueEvent} after removing all elements in a given {@literal keySpace}.
* {@link KeyValueEvent} after removing all elements in a given {@literal keyspace}.
*
* @author Christoph Strobl
* @param <T>
@@ -406,8 +406,8 @@ public class KeyValueEvent<T> extends ApplicationEvent {
@SuppressWarnings("serial")
public static class AfterDropKeySpaceEvent<T> extends KeyValueEvent<T> {
public AfterDropKeySpaceEvent(String keySpace, Class<? extends T> type) {
super(type, keySpace);
public AfterDropKeySpaceEvent(String keyspace, Class<? extends T> type) {
super(type, keyspace);
}
@Override

View File

@@ -17,7 +17,6 @@ package org.springframework.data.keyvalue.repository.support;
import static org.springframework.data.querydsl.QuerydslUtils.QUERY_DSL_PRESENT;
import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Optional;
@@ -126,7 +125,7 @@ public class KeyValueRepositoryFactory extends RepositoryFactorySupport {
@Override
protected Object getTargetRepository(RepositoryInformation repositoryInformation) {
EntityInformation<?, Serializable> entityInformation = getEntityInformation(repositoryInformation.getDomainType());
EntityInformation<?, ?> entityInformation = getEntityInformation(repositoryInformation.getDomainType());
return super.getTargetRepositoryViaReflection(repositoryInformation, entityInformation, keyValueOperations);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2016 the original author or authors.
* Copyright 2014-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,8 +15,6 @@
*/
package org.springframework.data.keyvalue.repository.support;
import java.io.Serializable;
import org.springframework.data.keyvalue.core.KeyValueOperations;
import org.springframework.data.keyvalue.repository.KeyValueRepository;
import org.springframework.data.keyvalue.repository.config.QueryCreatorType;
@@ -30,11 +28,12 @@ import org.springframework.util.Assert;
/**
* {@link org.springframework.beans.factory.FactoryBean} to create {@link KeyValueRepository}.
*
*
* @author Christoph Strobl
* @author Oliver Gierke
* @author Mark Paluch
*/
public class KeyValueRepositoryFactoryBean<T extends Repository<S, ID>, S, ID extends Serializable>
public class KeyValueRepositoryFactoryBean<T extends Repository<S, ID>, S, ID>
extends RepositoryFactoryBeanSupport<T, S, ID> {
private KeyValueOperations operations;
@@ -43,7 +42,7 @@ public class KeyValueRepositoryFactoryBean<T extends Repository<S, ID>, S, ID ex
/**
* Creates a new {@link KeyValueRepositoryFactoryBean} for the given repository interface.
*
*
* @param repositoryInterface must not be {@literal null}.
*/
public KeyValueRepositoryFactoryBean(Class<? extends T> repositoryInterface) {
@@ -52,7 +51,7 @@ public class KeyValueRepositoryFactoryBean<T extends Repository<S, ID>, S, ID ex
/**
* Configures the {@link KeyValueOperations} to be used for the repositories.
*
*
* @param operations must not be {@literal null}.
*/
public void setKeyValueOperations(KeyValueOperations operations) {
@@ -73,7 +72,7 @@ public class KeyValueRepositoryFactoryBean<T extends Repository<S, ID>, S, ID ex
/**
* Configures the {@link QueryCreatorType} to be used.
*
*
* @param queryCreator must not be {@literal null}.
*/
public void setQueryCreator(Class<? extends AbstractQueryCreator<?, ?>> queryCreator) {

View File

@@ -17,7 +17,6 @@ package org.springframework.data.keyvalue.repository.support;
import static org.springframework.data.keyvalue.repository.support.KeyValueQuerydslUtils.*;
import java.io.Serializable;
import java.util.Optional;
import org.springframework.dao.IncorrectResultSizeDataAccessException;
@@ -51,7 +50,7 @@ import com.querydsl.core.types.dsl.PathBuilder;
* @param <T> the domain type to manage
* @param <ID> the identifier type of the domain type
*/
public class QuerydslKeyValueRepository<T, ID extends Serializable> extends SimpleKeyValueRepository<T, ID>
public class QuerydslKeyValueRepository<T, ID> extends SimpleKeyValueRepository<T, ID>
implements QuerydslPredicateExecutor<T> {
private static final EntityPathResolver DEFAULT_ENTITY_PATH_RESOLVER = SimpleEntityPathResolver.INSTANCE;

View File

@@ -119,7 +119,7 @@ public class SimpleKeyValueRepository<T, ID> implements KeyValueRepository<T, ID
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#findOne(java.io.Serializable)
* @see org.springframework.data.repository.CrudRepository#findOne(java.lang.Object)
*/
@Override
public Optional<T> findById(ID id) {
@@ -128,7 +128,7 @@ public class SimpleKeyValueRepository<T, ID> implements KeyValueRepository<T, ID
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#exists(java.io.Serializable)
* @see org.springframework.data.repository.CrudRepository#exists(java.lang.Object)
*/
@Override
public boolean existsById(ID id) {
@@ -176,7 +176,7 @@ public class SimpleKeyValueRepository<T, ID> implements KeyValueRepository<T, ID
/*
* (non-Javadoc)
* @see org.springframework.data.repository.CrudRepository#delete(java.io.Serializable)
* @see org.springframework.data.repository.CrudRepository#delete(java.lang.Object)
*/
@Override
public void deleteById(ID id) {