From 864233e40cf4aa0dc8d4ed2d0dbe12313964b212 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Mon, 18 Feb 2019 14:10:29 +0300 Subject: [PATCH] Code formatted according to checkstyle rules --- redisson/pom.xml | 1 + .../transaction/BaseTransactionalMap.java | 44 +++++++++---------- .../transaction/BaseTransactionalSet.java | 8 ++-- .../org/redisson/transaction/HashKey.java | 1 + .../transaction/RedissonTransaction.java | 4 +- .../RedissonTransactionalBucket.java | 2 +- .../transaction/TransactionalSet.java | 10 ++--- .../transaction/TransactionalSetCache.java | 10 ++--- .../map/MapCacheFastPutIfAbsentOperation.java | 2 +- .../map/MapCacheFastPutOperation.java | 2 +- .../map/MapCachePutIfAbsentOperation.java | 2 +- .../operation/map/MapCachePutOperation.java | 2 +- .../operation/set/SetOperation.java | 4 +- 13 files changed, 47 insertions(+), 45 deletions(-) diff --git a/redisson/pom.xml b/redisson/pom.xml index e85df0e48..67172b157 100644 --- a/redisson/pom.xml +++ b/redisson/pom.xml @@ -380,6 +380,7 @@ **/org/redisson/remote/**/*.java, **/org/redisson/rx/**/*.java, **/org/redisson/spring/**/*.java, + **/org/redisson/transaction/**/*.java, true diff --git a/redisson/src/main/java/org/redisson/transaction/BaseTransactionalMap.java b/redisson/src/main/java/org/redisson/transaction/BaseTransactionalMap.java index 60e6e536f..df94c3683 100644 --- a/redisson/src/main/java/org/redisson/transaction/BaseTransactionalMap.java +++ b/redisson/src/main/java/org/redisson/transaction/BaseTransactionalMap.java @@ -109,7 +109,7 @@ public class BaseTransactionalMap { } HashValue toKeyHash(Object key) { - ByteBuf keyState = ((RedissonObject)map).encodeMapKey(key); + ByteBuf keyState = ((RedissonObject) map).encodeMapKey(key); try { return new HashValue(Hash.hash128(keyState)); } finally { @@ -189,7 +189,7 @@ public class BaseTransactionalMap { protected MapScanResult scanIterator(String name, RedisClient client, long startPos, String pattern, int count) { - MapScanResult res = ((RedissonMap)map).scanIterator(name, client, startPos, pattern, count); + MapScanResult res = ((RedissonMap) map).scanIterator(name, client, startPos, pattern, count); Map newstate = new HashMap(state); for (Iterator iterator = res.getMap().keySet().iterator(); iterator.hasNext();) { Object entry = iterator.next(); @@ -519,7 +519,7 @@ public class BaseTransactionalMap { if (entry == MapEntry.NULL) { return RedissonPromise.newSucceededFuture(null); } else { - ByteBuf valueState = ((RedissonObject)map).encodeMapValue(entry.getValue()); + ByteBuf valueState = ((RedissonObject) map).encodeMapValue(entry.getValue()); try { return RedissonPromise.newSucceededFuture(valueState.readableBytes()); } finally { @@ -538,10 +538,10 @@ public class BaseTransactionalMap { if (entry == MapEntry.NULL) { return RedissonPromise.newSucceededFuture(null); } else { - return RedissonPromise.newSucceededFuture((V)entry.getValue()); + return RedissonPromise.newSucceededFuture((V) entry.getValue()); } } - return ((RedissonMap)map).getOperationAsync(key); + return ((RedissonMap) map).getOperationAsync(key); } public RFuture> readAllKeySetAsync() { @@ -607,7 +607,7 @@ public class BaseTransactionalMap { } public RFuture> readAllMapAsync() { - RPromise> result = new RedissonPromise>(); + RPromise> result = new RedissonPromise<>(); RFuture> future = map.readAllMapAsync(); future.onComplete((map, e) -> { if (e != null) { @@ -615,7 +615,7 @@ public class BaseTransactionalMap { return; } - Map newstate = new HashMap(state); + Map newstate = new HashMap<>(state); for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) { K key = iterator.next(); MapEntry entry = newstate.remove(toKeyHash(key)); @@ -630,7 +630,7 @@ public class BaseTransactionalMap { if (entry == MapEntry.NULL) { continue; } - map.put((K)entry.getKey(), (V)entry.getValue()); + map.put((K) entry.getKey(), (V) entry.getValue()); } result.trySuccess(map); @@ -640,7 +640,7 @@ public class BaseTransactionalMap { } protected RFuture> getAllOperationAsync(Set keys) { - RPromise> result = new RedissonPromise>(); + RPromise> result = new RedissonPromise<>(); Set keysToLoad = new HashSet(keys); Map map = new HashMap(); for (K key : keys) { @@ -649,14 +649,14 @@ public class BaseTransactionalMap { MapEntry entry = state.get(keyHash); if (entry != null) { if (entry != MapEntry.NULL) { - map.put(key, (V)entry.getValue()); + map.put(key, (V) entry.getValue()); } } else { keysToLoad.add(key); } } - RFuture> future = ((RedissonMap)this.map).getAllOperationAsync(keysToLoad); + RFuture> future = ((RedissonMap) this.map).getAllOperationAsync(keysToLoad); future.onComplete((res, e) -> { if (e != null) { result.tryFailure(e); @@ -671,7 +671,7 @@ public class BaseTransactionalMap { } protected RFuture removeOperationAsync(K key) { - RPromise result = new RedissonPromise(); + RPromise result = new RedissonPromise<>(); executeLocked(result, key, new Runnable() { @Override public void run() { @@ -706,8 +706,8 @@ public class BaseTransactionalMap { } protected RFuture removeOperationAsync(Object key, Object value) { - RPromise result = new RedissonPromise(); - executeLocked(result, (K)key, new Runnable() { + RPromise result = new RedissonPromise<>(); + executeLocked(result, (K) key, new Runnable() { @Override public void run() { HashValue keyHash = toKeyHash(key); @@ -729,7 +729,7 @@ public class BaseTransactionalMap { return; } - map.getAsync((K)key).onComplete((r, e) -> { + map.getAsync((K) key).onComplete((r, e) -> { if (e != null) { result.tryFailure(e); return; @@ -747,8 +747,8 @@ public class BaseTransactionalMap { } private boolean isEqual(Object value, Object oldValue) { - ByteBuf valueBuf = ((RedissonObject)map).encodeMapValue(value); - ByteBuf oldValueBuf = ((RedissonObject)map).encodeMapValue(oldValue); + ByteBuf valueBuf = ((RedissonObject) map).encodeMapValue(value); + ByteBuf oldValueBuf = ((RedissonObject) map).encodeMapValue(oldValue); try { return valueBuf.equals(oldValueBuf); @@ -759,7 +759,7 @@ public class BaseTransactionalMap { } protected RFuture putAllOperationAsync(Map entries) { - RPromise result = new RedissonPromise(); + RPromise result = new RedissonPromise<>(); executeLocked(result, new Runnable() { @Override public void run() { @@ -775,12 +775,12 @@ public class BaseTransactionalMap { result.trySuccess(null); } - }, (Collection)entries.keySet()); + }, (Collection) entries.keySet()); return result; } protected RFuture replaceOperationAsync(K key, V oldValue, V newValue) { - RPromise result = new RedissonPromise(); + RPromise result = new RedissonPromise<>(); executeLocked(result, key, new Runnable() { @Override public void run() { @@ -822,7 +822,7 @@ public class BaseTransactionalMap { } protected RFuture replaceOperationAsync(K key, V value) { - RPromise result = new RedissonPromise(); + RPromise result = new RedissonPromise<>(); executeLocked(result, key, new Runnable() { @Override public void run() { @@ -878,7 +878,7 @@ public class BaseTransactionalMap { } protected void executeLocked(RPromise promise, Runnable runnable, Collection keys) { - List locks = new ArrayList(keys.size()); + List locks = new ArrayList<>(keys.size()); for (K key : keys) { RLock lock = getLock(key); locks.add(lock); diff --git a/redisson/src/main/java/org/redisson/transaction/BaseTransactionalSet.java b/redisson/src/main/java/org/redisson/transaction/BaseTransactionalSet.java index e550f279b..9fc985b96 100644 --- a/redisson/src/main/java/org/redisson/transaction/BaseTransactionalSet.java +++ b/redisson/src/main/java/org/redisson/transaction/BaseTransactionalSet.java @@ -78,7 +78,7 @@ public abstract class BaseTransactionalSet extends BaseTransactionalObject { } private HashValue toHash(Object value) { - ByteBuf state = ((RedissonObject)set).encode(value); + ByteBuf state = ((RedissonObject) set).encode(value); try { return new HashValue(Hash.hash128(state)); } finally { @@ -330,7 +330,7 @@ public abstract class BaseTransactionalSet extends BaseTransactionalObject { public RFuture removeAsync(Object value) { RPromise result = new RedissonPromise(); - executeLocked(result, (V)value, new Runnable() { + executeLocked(result, (V) value, new Runnable() { @Override public void run() { HashValue keyHash = toHash(value); @@ -508,8 +508,8 @@ public abstract class BaseTransactionalSet extends BaseTransactionalObject { } private boolean isEqual(Object value, Object oldValue) { - ByteBuf valueBuf = ((RedissonObject)set).encode(value); - ByteBuf oldValueBuf = ((RedissonObject)set).encode(oldValue); + ByteBuf valueBuf = ((RedissonObject) set).encode(value); + ByteBuf oldValueBuf = ((RedissonObject) set).encode(oldValue); try { return valueBuf.equals(oldValueBuf); diff --git a/redisson/src/main/java/org/redisson/transaction/HashKey.java b/redisson/src/main/java/org/redisson/transaction/HashKey.java index 218ed5279..2a1211b5f 100644 --- a/redisson/src/main/java/org/redisson/transaction/HashKey.java +++ b/redisson/src/main/java/org/redisson/transaction/HashKey.java @@ -41,6 +41,7 @@ public class HashKey { } @Override + @SuppressWarnings("AvoidInlineConditionals") public int hashCode() { final int prime = 31; int result = 1; diff --git a/redisson/src/main/java/org/redisson/transaction/RedissonTransaction.java b/redisson/src/main/java/org/redisson/transaction/RedissonTransaction.java index 0d880584f..65b8d92e9 100644 --- a/redisson/src/main/java/org/redisson/transaction/RedissonTransaction.java +++ b/redisson/src/main/java/org/redisson/transaction/RedissonTransaction.java @@ -333,7 +333,7 @@ public class RedissonTransaction implements RTransaction { for (TransactionalOperation transactionalOperation : operations) { if (localCaches.contains(transactionalOperation.getName())) { MapOperation mapOperation = (MapOperation) transactionalOperation; - RedissonLocalCachedMap map = (RedissonLocalCachedMap)mapOperation.getMap(); + RedissonLocalCachedMap map = (RedissonLocalCachedMap) mapOperation.getMap(); HashKey hashKey = new HashKey(transactionalOperation.getName(), transactionalOperation.getCodec()); byte[] key = map.toCacheKey(mapOperation.getKey()).getKeyHash(); @@ -427,7 +427,7 @@ public class RedissonTransaction implements RTransaction { for (TransactionalOperation transactionalOperation : operations) { if (localCaches.contains(transactionalOperation.getName())) { MapOperation mapOperation = (MapOperation) transactionalOperation; - RedissonLocalCachedMap map = (RedissonLocalCachedMap)mapOperation.getMap(); + RedissonLocalCachedMap map = (RedissonLocalCachedMap) mapOperation.getMap(); HashKey hashKey = new HashKey(transactionalOperation.getName(), transactionalOperation.getCodec()); byte[] key = map.toCacheKey(mapOperation.getKey()).getKeyHash(); diff --git a/redisson/src/main/java/org/redisson/transaction/RedissonTransactionalBucket.java b/redisson/src/main/java/org/redisson/transaction/RedissonTransactionalBucket.java index 5eff06703..99fd1e6df 100644 --- a/redisson/src/main/java/org/redisson/transaction/RedissonTransactionalBucket.java +++ b/redisson/src/main/java/org/redisson/transaction/RedissonTransactionalBucket.java @@ -231,7 +231,7 @@ public class RedissonTransactionalBucket extends RedissonBucket { if (state == NULL) { return RedissonPromise.newSucceededFuture(null); } else { - return RedissonPromise.newSucceededFuture((V)state); + return RedissonPromise.newSucceededFuture((V) state); } } diff --git a/redisson/src/main/java/org/redisson/transaction/TransactionalSet.java b/redisson/src/main/java/org/redisson/transaction/TransactionalSet.java index 945c24719..356548ee7 100644 --- a/redisson/src/main/java/org/redisson/transaction/TransactionalSet.java +++ b/redisson/src/main/java/org/redisson/transaction/TransactionalSet.java @@ -52,7 +52,7 @@ public class TransactionalSet extends BaseTransactionalSet { @Override protected ListScanResult scanIteratorSource(String name, RedisClient client, long startPos, String pattern, int count) { - return ((RedissonSet)set).scanIterator(name, client, startPos, pattern, count); + return ((RedissonSet) set).scanIterator(name, client, startPos, pattern, count); } @Override @@ -61,23 +61,23 @@ public class TransactionalSet extends BaseTransactionalSet { } @Override - protected TransactionalOperation createAddOperation(final V value) { + protected TransactionalOperation createAddOperation(V value) { return new AddOperation(set, value, transactionId); } @Override - protected MoveOperation createMoveOperation(final String destination, final V value, final long threadId) { + protected MoveOperation createMoveOperation(String destination, V value, long threadId) { return new MoveOperation(set, destination, threadId, value, transactionId); } @Override - protected TransactionalOperation createRemoveOperation(final Object value) { + protected TransactionalOperation createRemoveOperation(Object value) { return new RemoveOperation(set, value, transactionId); } @Override protected RLock getLock(RCollectionAsync set, V value) { - String lockName = ((RedissonSet)set).getLockName(value, "lock"); + String lockName = ((RedissonSet) set).getLockName(value, "lock"); return new RedissonTransactionalLock(commandExecutor, lockName, transactionId); } diff --git a/redisson/src/main/java/org/redisson/transaction/TransactionalSetCache.java b/redisson/src/main/java/org/redisson/transaction/TransactionalSetCache.java index e206eefa1..7335c9d9c 100644 --- a/redisson/src/main/java/org/redisson/transaction/TransactionalSetCache.java +++ b/redisson/src/main/java/org/redisson/transaction/TransactionalSetCache.java @@ -53,7 +53,7 @@ public class TransactionalSetCache extends BaseTransactionalSet { @Override protected ListScanResult scanIteratorSource(String name, RedisClient client, long startPos, String pattern, int count) { - return ((RedissonSetCache)set).scanIterator(name, client, startPos, pattern, count); + return ((RedissonSetCache) set).scanIterator(name, client, startPos, pattern, count); } @Override @@ -66,23 +66,23 @@ public class TransactionalSetCache extends BaseTransactionalSet { } @Override - protected TransactionalOperation createAddOperation(final V value) { + protected TransactionalOperation createAddOperation(V value) { return new AddCacheOperation(set, value, transactionId); } @Override - protected MoveOperation createMoveOperation(final String destination, final V value, final long threadId) { + protected MoveOperation createMoveOperation(String destination, V value, long threadId) { throw new UnsupportedOperationException(); } @Override - protected TransactionalOperation createRemoveOperation(final Object value) { + protected TransactionalOperation createRemoveOperation(Object value) { return new RemoveCacheOperation(set, value, transactionId); } @Override protected RLock getLock(RCollectionAsync set, V value) { - String lockName = ((RedissonSetCache)set).getLockName(value, "lock"); + String lockName = ((RedissonSetCache) set).getLockName(value, "lock"); return new RedissonTransactionalLock(commandExecutor, lockName, transactionId); } diff --git a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutIfAbsentOperation.java b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutIfAbsentOperation.java index b77cb4d8b..1941b87ed 100644 --- a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutIfAbsentOperation.java +++ b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutIfAbsentOperation.java @@ -43,7 +43,7 @@ public class MapCacheFastPutIfAbsentOperation extends MapOperation { @Override public void commit(RMap map) { - ((RMapCache)map).fastPutIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit); + ((RMapCache) map).fastPutIfAbsentAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit); } public long getTTL() { diff --git a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutOperation.java b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutOperation.java index e32802b6b..fe8685cce 100644 --- a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutOperation.java +++ b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCacheFastPutOperation.java @@ -45,7 +45,7 @@ public class MapCacheFastPutOperation extends MapOperation { @Override public void commit(RMap map) { - ((RMapCache)map).fastPutAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit); + ((RMapCache) map).fastPutAsync(key, value, ttl, ttlUnit, maxIdleTime, maxIdleUnit); } public long getTTL() { diff --git a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutIfAbsentOperation.java b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutIfAbsentOperation.java index b54abfa5f..f61d484e6 100644 --- a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutIfAbsentOperation.java +++ b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutIfAbsentOperation.java @@ -50,7 +50,7 @@ public class MapCachePutIfAbsentOperation extends MapOperation { @Override public void commit(RMap map) { - ((RMapCache)map).putIfAbsentAsync(key, value, ttl, unit, maxIdleTime, maxIdleUnit); + ((RMapCache) map).putIfAbsentAsync(key, value, ttl, unit, maxIdleTime, maxIdleUnit); } public long getTTL() { diff --git a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutOperation.java b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutOperation.java index 3a6a2ef19..0cfec77f7 100644 --- a/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutOperation.java +++ b/redisson/src/main/java/org/redisson/transaction/operation/map/MapCachePutOperation.java @@ -45,7 +45,7 @@ public class MapCachePutOperation extends MapOperation { @Override public void commit(RMap map) { - ((RMapCache)map).putAsync(key, value, ttlTimeout, ttlUnit, maxIdleTimeout, maxIdleUnit); + ((RMapCache) map).putAsync(key, value, ttlTimeout, ttlUnit, maxIdleTimeout, maxIdleUnit); } public long getTTL() { diff --git a/redisson/src/main/java/org/redisson/transaction/operation/set/SetOperation.java b/redisson/src/main/java/org/redisson/transaction/operation/set/SetOperation.java index 7417222a0..f9acf5a86 100644 --- a/redisson/src/main/java/org/redisson/transaction/operation/set/SetOperation.java +++ b/redisson/src/main/java/org/redisson/transaction/operation/set/SetOperation.java @@ -40,12 +40,12 @@ public abstract class SetOperation extends TransactionalOperation { } protected RLock getLock(RSetCache setCache, CommandAsyncExecutor commandExecutor, Object value) { - String lockName = ((RedissonSetCache)setCache).getLockName(value, "lock"); + String lockName = ((RedissonSetCache) setCache).getLockName(value, "lock"); return new RedissonTransactionalLock(commandExecutor, lockName, transactionId); } protected RLock getLock(RSet setCache, CommandAsyncExecutor commandExecutor, Object value) { - String lockName = ((RedissonSet)setCache).getLockName(value, "lock"); + String lockName = ((RedissonSet) setCache).getLockName(value, "lock"); return new RedissonTransactionalLock(commandExecutor, lockName, transactionId); }