diff --git a/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java b/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java index e3897c1..3665526 100644 --- a/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java +++ b/src/main/java/org/springframework/data/keyvalue/core/query/KeyValueQuery.java @@ -22,6 +22,7 @@ import org.springframework.util.Assert; /** * @author Christoph Strobl * @author Mark Paluch + * @author Marcel Overdijk * @param Criteria type */ public class KeyValueQuery { @@ -45,6 +46,17 @@ public class KeyValueQuery { this.criteria = criteria; } + /** + * Creates new instance of {@link KeyValueQuery} with given criteria and {@link Sort}. + * + * @param criteria can be {@literal null}. + * @param sort must not be {@literal null}. + */ + public KeyValueQuery(@Nullable T criteria, Sort sort) { + this.criteria = criteria; + setSort(sort); + } + /** * Creates new instance of {@link KeyValueQuery} with given {@link Sort}. * diff --git a/src/main/java/org/springframework/data/map/MapKeyValueAdapter.java b/src/main/java/org/springframework/data/map/MapKeyValueAdapter.java index e17f701..0ce3a4e 100644 --- a/src/main/java/org/springframework/data/map/MapKeyValueAdapter.java +++ b/src/main/java/org/springframework/data/map/MapKeyValueAdapter.java @@ -24,6 +24,7 @@ import org.springframework.core.CollectionFactory; import org.springframework.data.keyvalue.core.AbstractKeyValueAdapter; import org.springframework.data.keyvalue.core.ForwardingCloseableIterator; import org.springframework.data.keyvalue.core.KeyValueAdapter; +import org.springframework.data.keyvalue.core.QueryEngine; import org.springframework.data.util.CloseableIterator; import org.springframework.util.Assert; import org.springframework.util.ClassUtils; @@ -33,6 +34,7 @@ import org.springframework.util.ClassUtils; * * @author Christoph Strobl * @author Derek Cochran + * @author Marcel Overdijk */ public class MapKeyValueAdapter extends AbstractKeyValueAdapter { @@ -47,6 +49,15 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter { this(ConcurrentHashMap.class); } + /** + * Create new {@link MapKeyValueAdapter} using the given query engine. + * + * @param engine the query engine + */ + public MapKeyValueAdapter(QueryEngine engine) { + this(ConcurrentHashMap.class, engine); + } + /** * Creates a new {@link MapKeyValueAdapter} using the given {@link Map} as backing store. * @@ -54,7 +65,18 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter { */ @SuppressWarnings("rawtypes") public MapKeyValueAdapter(Class mapType) { - this(CollectionFactory.createMap(mapType, 100), mapType); + this(CollectionFactory.createMap(mapType, 100), mapType, null); + } + + /** + * Creates a new {@link MapKeyValueAdapter} using the given {@link Map} as backing store and query engine. + * + * @param mapType must not be {@literal null}. + * @param engine the query engine + */ + @SuppressWarnings("rawtypes") + public MapKeyValueAdapter(Class mapType, QueryEngine engine) { + this(CollectionFactory.createMap(mapType, 100), mapType, engine); } /** @@ -64,17 +86,30 @@ public class MapKeyValueAdapter extends AbstractKeyValueAdapter { */ @SuppressWarnings({ "rawtypes", "unchecked" }) public MapKeyValueAdapter(Map> store) { - this(store, (Class) ClassUtils.getUserClass(store)); + this(store, (Class) ClassUtils.getUserClass(store), null); } /** - * Creates a new {@link MapKeyValueAdapter} with the given store and type to be used when creating key spaces. + * Create new instance of {@link MapKeyValueAdapter} using given dataStore for persistence and query engine. + * + * @param store must not be {@literal null}. + * @param engine the query engine + */ + @SuppressWarnings({ "rawtypes", "unchecked" }) + public MapKeyValueAdapter(Map> store, QueryEngine engine) { + this(store, (Class) ClassUtils.getUserClass(store), engine); + } + + /** + * Creates a new {@link MapKeyValueAdapter} with the given store and type to be used when creating key spaces and query engine. * * @param store must not be {@literal null}. * @param keySpaceMapType must not be {@literal null}. + * @param engine the query engine */ @SuppressWarnings("rawtypes") - private MapKeyValueAdapter(Map> store, Class keySpaceMapType) { + private MapKeyValueAdapter(Map> store, Class keySpaceMapType, QueryEngine engine) { + super(engine); Assert.notNull(store, "Store must not be null."); Assert.notNull(keySpaceMapType, "Map type to be used for key spaces must not be null!");