Skip to content

Commit 14da42f

Browse files
committed
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.
1 parent d6ee87a commit 14da42f

16 files changed

+197
-489
lines changed

src/main/asciidoc/key-value-repositories.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ interface KeyValueOperations {
2020
2121
void delete(Class<?> type); <3>
2222
23-
<T> T findById(Serializable id, Class<T> type); <4>
23+
<T> T findById(Object id, Class<T> type); <4>
2424
2525
<T> Iterable<T> findAllOf(Class<T> type); <5>
2626

src/main/java/org/springframework/data/keyvalue/core/AbstractKeyValueAdapter.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* {@literal count} execution to.
2525
*
2626
* @author Christoph Strobl
27+
* @author Mark Paluch
2728
*/
2829
public abstract class AbstractKeyValueAdapter implements KeyValueAdapter {
2930

@@ -43,7 +44,7 @@ protected AbstractKeyValueAdapter() {
4344
*/
4445
protected AbstractKeyValueAdapter(QueryEngine<? extends KeyValueAdapter, ?, ?> engine) {
4546

46-
this.engine = engine != null ? engine : new SpelQueryEngine<>();
47+
this.engine = engine != null ? engine : new SpelQueryEngine();
4748
this.engine.registerAdapter(this);
4849
}
4950

@@ -62,7 +63,7 @@ protected AbstractKeyValueAdapter(QueryEngine<? extends KeyValueAdapter, ?, ?> e
6263
*/
6364
@Override
6465
public <T> T get(Object id, String keyspace, Class<T> type) {
65-
return (T) get(id, keyspace);
66+
return type.cast(get(id, keyspace));
6667
}
6768

6869
/*
@@ -71,7 +72,7 @@ public <T> T get(Object id, String keyspace, Class<T> type) {
7172
*/
7273
@Override
7374
public <T> T delete(Object id, String keyspace, Class<T> type) {
74-
return (T) delete(id, keyspace);
75+
return type.cast(delete(id, keyspace));
7576
}
7677

7778
/*

src/main/java/org/springframework/data/keyvalue/core/KeyValueOperations.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,22 @@
2525

2626
/**
2727
* Interface that specifies a basic set of key/value operations. Implemented by {@link KeyValueTemplate}.
28-
*
28+
*
2929
* @author Christoph Strobl
3030
*/
3131
public interface KeyValueOperations extends DisposableBean {
3232

3333
/**
3434
* Add given object. Object needs to have id property to which a generated value will be assigned.
35-
*
35+
*
3636
* @param objectToInsert
3737
* @return
3838
*/
3939
<T> T insert(T objectToInsert);
4040

4141
/**
4242
* Add object with given id.
43-
*
43+
*
4444
* @param id must not be {@literal null}.
4545
* @param objectToInsert must not be {@literal null}.
4646
*/
@@ -49,7 +49,7 @@ public interface KeyValueOperations extends DisposableBean {
4949
/**
5050
* Get all elements of given type. Respects {@link KeySpace} if present and therefore returns all elements that can be
5151
* assigned to requested type.
52-
*
52+
*
5353
* @param type must not be {@literal null}.
5454
* @return empty iterable if no elements found.
5555
*/
@@ -58,7 +58,7 @@ public interface KeyValueOperations extends DisposableBean {
5858
/**
5959
* Get all elements ordered by sort. Respects {@link KeySpace} if present and therefore returns all elements that can
6060
* be assigned to requested type.
61-
*
61+
*
6262
* @param sort must not be {@literal null}.
6363
* @param type must not be {@literal null}.
6464
* @return
@@ -68,16 +68,16 @@ public interface KeyValueOperations extends DisposableBean {
6868
/**
6969
* Get element of given type with given id. Respects {@link KeySpace} if present and therefore returns all elements
7070
* that can be assigned to requested type.
71-
*
71+
*
7272
* @param id must not be {@literal null}.
7373
* @param type must not be {@literal null}.
74-
* @return null if not found.
74+
* @return {@link Optional#empty()} if not found.
7575
*/
7676
<T> Optional<T> findById(Object id, Class<T> type);
7777

7878
/**
7979
* Execute operation against underlying store.
80-
*
80+
*
8181
* @param action must not be {@literal null}.
8282
* @return
8383
*/
@@ -86,7 +86,7 @@ public interface KeyValueOperations extends DisposableBean {
8686
/**
8787
* Get all elements matching the given query. <br />
8888
* Respects {@link KeySpace} if present and therefore returns all elements that can be assigned to requested type..
89-
*
89+
*
9090
* @param query must not be {@literal null}.
9191
* @param type must not be {@literal null}.
9292
* @return empty iterable if no match found.
@@ -96,7 +96,7 @@ public interface KeyValueOperations extends DisposableBean {
9696
/**
9797
* Get all elements in given range. Respects {@link KeySpace} if present and therefore returns all elements that can
9898
* be assigned to requested type.
99-
*
99+
*
100100
* @param offset
101101
* @param rows
102102
* @param type must not be {@literal null}.
@@ -107,7 +107,7 @@ public interface KeyValueOperations extends DisposableBean {
107107
/**
108108
* Get all elements in given range ordered by sort. Respects {@link KeySpace} if present and therefore returns all
109109
* elements that can be assigned to requested type.
110-
*
110+
*
111111
* @param offset
112112
* @param rows
113113
* @param sort
@@ -130,7 +130,7 @@ public interface KeyValueOperations extends DisposableBean {
130130
/**
131131
* Remove all elements of type. Respects {@link KeySpace} if present and therefore removes all elements that can be
132132
* assigned to requested type.
133-
*
133+
*
134134
* @param type must not be {@literal null}.
135135
*/
136136
void delete(Class<?> type);
@@ -143,7 +143,7 @@ public interface KeyValueOperations extends DisposableBean {
143143

144144
/**
145145
* Delete item of type with given id.
146-
*
146+
*
147147
* @param id must not be {@literal null}.
148148
* @param type must not be {@literal null}.
149149
* @return the deleted item or {@literal null} if no match found.
@@ -153,7 +153,7 @@ public interface KeyValueOperations extends DisposableBean {
153153
/**
154154
* Total number of elements with given type available. Respects {@link KeySpace} if present and therefore counts all
155155
* elements that can be assigned to requested type.
156-
*
156+
*
157157
* @param type must not be {@literal null}.
158158
* @return
159159
*/
@@ -162,7 +162,7 @@ public interface KeyValueOperations extends DisposableBean {
162162
/**
163163
* Total number of elements matching given query. Respects {@link KeySpace} if present and therefore counts all
164164
* elements that can be assigned to requested type.
165-
*
165+
*
166166
* @param query
167167
* @param type
168168
* @return

0 commit comments

Comments
 (0)