Skip to content

Commit bb19a9a

Browse files
christophstroblmp911de
authored andcommitted
DATAREDIS-664 - Adapt to ID type changes in KV module.
Related issue: DATAKV-187 Related pull request: spring-projects/spring-data-keyvalue#25 Original pull request: #256.
1 parent b0d139a commit bb19a9a

File tree

3 files changed

+43
-38
lines changed

3 files changed

+43
-38
lines changed

src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.data.redis.core;
1717

18-
import java.io.Serializable;
1918
import java.util.ArrayList;
2019
import java.util.Collection;
2120
import java.util.Collections;
@@ -196,9 +195,10 @@ protected RedisKeyValueAdapter() {}
196195

197196
/*
198197
* (non-Javadoc)
199-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#put(java.io.Serializable, java.lang.Object, java.io.Serializable)
198+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#put(java.lang.Object, java.lang.Object, java.lang.String)
200199
*/
201-
public Object put(final Serializable id, final Object item, final Serializable keyspace) {
200+
@Override
201+
public Object put(final Object id, final Object item, final String keyspace) {
202202

203203
final RedisData rdo = item instanceof RedisData ? (RedisData) item : new RedisData();
204204
if (!(item instanceof RedisData)) {
@@ -265,9 +265,10 @@ public Object doInRedis(RedisConnection connection) throws DataAccessException {
265265

266266
/*
267267
* (non-Javadoc)
268-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#contains(java.io.Serializable, java.io.Serializable)
268+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#contains(java.lang.Object, java.lang.String)
269269
*/
270-
public boolean contains(final Serializable id, final Serializable keyspace) {
270+
@Override
271+
public boolean contains(final Object id, final String keyspace) {
271272

272273
Boolean exists = redisOps.execute(new RedisCallback<Boolean>() {
273274

@@ -282,19 +283,19 @@ public Boolean doInRedis(RedisConnection connection) throws DataAccessException
282283

283284
/*
284285
* (non-Javadoc)
285-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.io.Serializable, java.io.Serializable)
286+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.lang.Object, java.lang.String)
286287
*/
287-
public Object get(Serializable id, Serializable keyspace) {
288+
@Override
289+
public Object get(Object id, String keyspace) {
288290
return get(id, keyspace, Object.class);
289291
}
290292

291-
/**
292-
* @param id
293-
* @param keyspace
294-
* @param type
295-
* @return
293+
/*
294+
* (non-Javadoc)
295+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#get(java.lang.Object, java.lang.String, java.lang.Class)
296296
*/
297-
public <T> T get(Serializable id, Serializable keyspace, Class<T> type) {
297+
@Override
298+
public <T> T get(Object id, String keyspace, Class<T> type) {
298299

299300
String stringId = asString(id);
300301
String stringKeyspace = asString(keyspace);
@@ -318,17 +319,19 @@ public Map<byte[], byte[]> doInRedis(RedisConnection connection) throws DataAcce
318319

319320
/*
320321
* (non-Javadoc)
321-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#delete(java.io.Serializable, java.io.Serializable)
322+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#delete(java.lang.Object, java.lang.String)
322323
*/
323-
public Object delete(final Serializable id, final Serializable keyspace) {
324+
@Override
325+
public Object delete(final Object id, final String keyspace) {
324326
return delete(id, keyspace, Object.class);
325327
}
326328

327329
/*
328330
* (non-Javadoc)
329-
* @see org.springframework.data.keyvalue.core.AbstractKeyValueAdapter#delete(java.io.Serializable, java.io.Serializable, java.lang.Class)
331+
* @see org.springframework.data.keyvalue.core.AbstractKeyValueAdapter#delete(java.lang.Object, java.lang.String, java.lang.Class)
330332
*/
331-
public <T> T delete(final Serializable id, final Serializable keyspace, final Class<T> type) {
333+
@Override
334+
public <T> T delete(final Object id, final String keyspace, final Class<T> type) {
332335

333336
final byte[] binId = toBytes(id);
334337
final byte[] binKeyspace = toBytes(keyspace);
@@ -358,13 +361,14 @@ public Void doInRedis(RedisConnection connection) throws DataAccessException {
358361

359362
/*
360363
* (non-Javadoc)
361-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#getAllOf(java.io.Serializable)
364+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#getAllOf(java.lang.String)
362365
*/
363-
public List<?> getAllOf(final Serializable keyspace) {
366+
@Override
367+
public List<?> getAllOf(final String keyspace) {
364368
return getAllOf(keyspace, -1, -1);
365369
}
366370

367-
public List<?> getAllOf(final Serializable keyspace, long offset, int rows) {
371+
public List<?> getAllOf(final String keyspace, long offset, int rows) {
368372

369373
final byte[] binKeyspace = toBytes(keyspace);
370374

@@ -397,9 +401,10 @@ public Set<byte[]> doInRedis(RedisConnection connection) throws DataAccessExcept
397401

398402
/*
399403
* (non-Javadoc)
400-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#deleteAllOf(java.io.Serializable)
404+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#deleteAllOf(java.lang.String)
401405
*/
402-
public void deleteAllOf(final Serializable keyspace) {
406+
@Override
407+
public void deleteAllOf(final String keyspace) {
403408

404409
redisOps.execute(new RedisCallback<Void>() {
405410

@@ -415,17 +420,19 @@ public Void doInRedis(RedisConnection connection) throws DataAccessException {
415420

416421
/*
417422
* (non-Javadoc)
418-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#entries(java.io.Serializable)
423+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#entries(java.lang.String)
419424
*/
420-
public CloseableIterator<Entry<Serializable, Object>> entries(Serializable keyspace) {
425+
@Override
426+
public CloseableIterator<Entry<Object, Object>> entries(String keyspace) {
421427
throw new UnsupportedOperationException("Not yet implemented");
422428
}
423429

424430
/*
425431
* (non-Javadoc)
426-
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#count(java.io.Serializable)
432+
* @see org.springframework.data.keyvalue.core.KeyValueAdapter#count(java.lang.String)
427433
*/
428-
public long count(final Serializable keyspace) {
434+
@Override
435+
public long count(final String keyspace) {
429436

430437
Long count = redisOps.execute(new RedisCallback<Long>() {
431438

@@ -592,7 +599,7 @@ public void clear() {
592599
// nothing to do
593600
}
594601

595-
private String asString(Serializable value) {
602+
private String asString(Object value) {
596603
return value instanceof String ? (String) value
597604
: getConverter().getConversionService().convert(value, String.class);
598605
}

src/main/java/org/springframework/data/redis/core/RedisKeyValueTemplate.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2015 the original author or authors.
2+
* Copyright 2015-2017 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.data.redis.core;
1717

18-
import java.io.Serializable;
1918
import java.util.ArrayList;
2019
import java.util.Collections;
2120
import java.util.List;
@@ -114,10 +113,10 @@ public List<T> doInRedis(RedisKeyValueAdapter adapter) {
114113

115114
/*
116115
* (non-Javadoc)
117-
* @see org.springframework.data.keyvalue.core.KeyValueTemplate#insert(java.io.Serializable, java.lang.Object)
116+
* @see org.springframework.data.keyvalue.core.KeyValueTemplate#insert(java.lang.Object, java.lang.Object)
118117
*/
119118
@Override
120-
public void insert(final Serializable id, final Object objectToInsert) {
119+
public void insert(final Object id, final Object objectToInsert) {
121120

122121
if (objectToInsert instanceof PartialUpdate) {
123122
doPartialUpdate((PartialUpdate<?>) objectToInsert);

src/main/java/org/springframework/data/redis/core/RedisQueryEngine.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.data.redis.core;
1717

18-
import java.io.Serializable;
1918
import java.util.ArrayList;
2019
import java.util.Collection;
2120
import java.util.Collections;
@@ -72,12 +71,12 @@ public RedisQueryEngine(CriteriaAccessor<RedisOperationChain> criteriaAccessor,
7271

7372
/*
7473
* (non-Javadoc)
75-
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.io.Serializable, java.lang.Class)
74+
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String, java.lang.Class)
7675
*/
7776
@Override
7877
@SuppressWarnings("unchecked")
7978
public <T> Collection<T> execute(final RedisOperationChain criteria, final Comparator<?> sort, final long offset,
80-
final int rows, final Serializable keyspace, Class<T> type) {
79+
final int rows, final String keyspace, Class<T> type) {
8180

8281
if (criteria == null
8382
|| (CollectionUtils.isEmpty(criteria.getOrSismember()) && CollectionUtils.isEmpty(criteria.getSismember()))
@@ -151,20 +150,20 @@ public Map<byte[], Map<byte[], byte[]>> doInRedis(RedisConnection connection) th
151150

152151
/*
153152
* (non-Javadoc)
154-
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.io.Serializable)
153+
* @see org.springframework.data.keyvalue.core.QueryEngine#execute(java.lang.Object, java.lang.Object, int, int, java.lang.String)
155154
*/
156155
@Override
157156
public Collection<?> execute(final RedisOperationChain criteria, Comparator<?> sort, long offset, int rows,
158-
final Serializable keyspace) {
157+
final String keyspace) {
159158
return execute(criteria, sort, offset, rows, keyspace, Object.class);
160159
}
161160

162161
/*
163162
* (non-Javadoc)
164-
* @see org.springframework.data.keyvalue.core.QueryEngine#count(java.lang.Object, java.io.Serializable)
163+
* @see org.springframework.data.keyvalue.core.QueryEngine#count(java.lang.Object, java.lang.String)
165164
*/
166165
@Override
167-
public long count(final RedisOperationChain criteria, final Serializable keyspace) {
166+
public long count(final RedisOperationChain criteria, final String keyspace) {
168167

169168
if (criteria == null) {
170169
return this.getAdapter().count(keyspace);

0 commit comments

Comments
 (0)