Code formatted according to checkstyle rules

pull/1923/head
Nikita Koksharov 6 years ago
parent a5bb755deb
commit bd4c70ebd6

@ -373,6 +373,12 @@
**/org/redisson/executor/**/*.java,
**/org/redisson/jcache/**/*.java,
**/org/redisson/liveobject/**/*.java,
**/org/redisson/mapreduce/**/*.java,
**/org/redisson/misc/**/*.java,
**/org/redisson/pubsub/**/*.java,
**/org/redisson/reactive/**/*.java,
**/org/redisson/remote/**/*.java,
**/org/redisson/rx/**/*.java,
</includes>
<consoleOutput>true</consoleOutput>
<enableRSS>false</enableRSS>

@ -218,7 +218,7 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"end; " +
"return 1; ",
Arrays.<Object>asList(getName(), threadsQueueName, timeoutSetName, getChannelName()),
LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId), System.currentTimeMillis());
LockPubSub.UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId), System.currentTimeMillis());
}
@Override
@ -296,7 +296,7 @@ public class RedissonFairLock extends RedissonLock implements RLock {
"end; " +
"return 0;",
Arrays.<Object>asList(getName(), threadsQueueName, timeoutSetName, getChannelName()),
LockPubSub.unlockMessage, System.currentTimeMillis());
LockPubSub.UNLOCK_MESSAGE, System.currentTimeMillis());
}
}

@ -421,7 +421,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
+ "else "
+ "return 0 "
+ "end",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE);
}
@Override
@ -486,7 +486,7 @@ public class RedissonLock extends RedissonExpirable implements RLock {
"return 1; "+
"end; " +
"return nil;",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage, internalLockLeaseTime, getLockName(threadId));
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId));
}

@ -129,7 +129,7 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"redis.call('publish', KEYS[2], ARGV[1]); " +
"return 1; ",
Arrays.<Object>asList(getName(), getChannelName(), timeoutPrefix, keyPrefix),
LockPubSub.unlockMessage, getLockName(threadId));
LockPubSub.UNLOCK_MESSAGE, getLockName(threadId));
}
protected String getKeyPrefix(long threadId, String timeoutPrefix) {
@ -180,7 +180,7 @@ public class RedissonReadLock extends RedissonLock implements RLock {
"return 1; " +
"end; " +
"return 0; ",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.unlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.UNLOCK_MESSAGE);
}
@Override

@ -107,7 +107,7 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
"end; "
+ "return nil;",
Arrays.<Object>asList(getName(), getChannelName()),
LockPubSub.readUnlockMessage, internalLockLeaseTime, getLockName(threadId));
LockPubSub.READ_UNLOCK_MESSAGE, internalLockLeaseTime, getLockName(threadId));
}
@Override
@ -125,7 +125,7 @@ public class RedissonWriteLock extends RedissonLock implements RLock {
"return 1; " +
"end; " +
"return 0; ",
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.readUnlockMessage);
Arrays.<Object>asList(getName(), getChannelName()), LockPubSub.READ_UNLOCK_MESSAGE);
}
@Override

@ -60,7 +60,7 @@ abstract class MapReduceExecutor<M, VIn, KOut, VOut> implements RMapReduceExecut
M mapper;
long timeout;
public MapReduceExecutor(RObject object, RedissonClient redisson, ConnectionManager connectionManager) {
MapReduceExecutor(RObject object, RedissonClient redisson, ConnectionManager connectionManager) {
this.objectName = object.getName();
this.objectCodec = object.getCodec();
this.objectClass = object.getClass();

@ -23,44 +23,44 @@ import java.util.NoSuchElementException;
*/
public class CompositeIterator<T> implements Iterator<T> {
private Iterator<Iterator<T>> listIterator;
private Iterator<T> currentIterator;
private Iterator<Iterator<T>> listIterator;
private Iterator<T> currentIterator;
public CompositeIterator(Iterator<Iterator<T>> iterators) {
listIterator = iterators;
}
public CompositeIterator(Iterator<Iterator<T>> iterators) {
listIterator = iterators;
}
@Override
public boolean hasNext() {
if (currentIterator == null || !currentIterator.hasNext()) {
while (listIterator.hasNext()) {
Iterator<T> iterator = listIterator.next();
currentIterator = iterator;
if (iterator.hasNext()) {
return true;
}
}
return false;
}
@Override
public boolean hasNext() {
if (currentIterator == null || !currentIterator.hasNext()) {
while (listIterator.hasNext()) {
Iterator<T> iterator = listIterator.next();
currentIterator = iterator;
if (iterator.hasNext()) {
return true;
}
}
return false;
}
return currentIterator.hasNext();
}
return currentIterator.hasNext();
}
@Override
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
@Override
public T next() {
if (!hasNext()) {
throw new NoSuchElementException();
}
return currentIterator.next();
}
return currentIterator.next();
}
@Override
public void remove() {
if (currentIterator == null) {
throw new IllegalStateException("next() has not yet been called");
}
@Override
public void remove() {
if (currentIterator == null) {
throw new IllegalStateException("next() has not yet been called");
}
currentIterator.remove();
}
currentIterator.remove();
}
}

@ -25,7 +25,7 @@ import io.netty.util.CharsetUtil;
* @author Nikita Koksharov
*
*/
public class Hash {
public final class Hash {
private static final long[] KEY = {0x9e3779b97f4a7c15L, 0xf39cc0605cedc834L, 0x1082276bf3a27251L, 0xf86c6a11d0c18e95L};

@ -19,6 +19,7 @@ package org.redisson.misc;
* HighwayHash algorithm. See <a href="https://github.com/google/highwayhash">
* HighwayHash on GitHub</a>
*/
@SuppressWarnings({"OperatorWrap", "BooleanExpressionComplexity", "UnnecessaryParentheses", "WhitespaceAfter", "ParameterName", "LocalVariableName"})
public final class HighwayHash {
private final long[] v0 = new long[4];
private final long[] v1 = new long[4];

@ -25,6 +25,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* @author Nikita Koksharov
*/
// TODO refactor to AbstractQueuedLongSynchronizer
@SuppressWarnings({"MultipleVariableDeclarations", "AvoidInlineConditionals", "UpperEll"})
public class InfinitySemaphoreLatch extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1744280161777661090l;

@ -22,16 +22,15 @@ import org.redisson.client.protocol.CommandData;
import org.redisson.client.protocol.RedisCommands;
import io.netty.buffer.ByteBuf;
import io.netty.util.CharsetUtil;
/**
* @author Philipp Marx
*/
public class LogHelper {
public final class LogHelper {
private static final int MAX_COLLECTION_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxCollectionLogSize", "10"));
private static final int MAX_STRING_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxStringLogSize", "100"));
private static final int MAX_BYTEBUF_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxByteBufLogSize", "1000"));
// private static final int MAX_BYTEBUF_LOG_SIZE = Integer.valueOf(System.getProperty("redisson.maxByteBufLogSize", "1000"));
private LogHelper() {
}
@ -46,7 +45,7 @@ public class LogHelper {
} else if (object instanceof Collection) {
return toCollectionString((Collection<?>) object);
} else if (object instanceof CommandData) {
CommandData<?, ?> cd = (CommandData<?, ?>)object;
CommandData<?, ?> cd = (CommandData<?, ?>) object;
if (RedisCommands.AUTH.equals(cd.getCommand())) {
return cd.getCommand() + ", params: (password masked)";
}

@ -42,13 +42,14 @@ public class ProxyBuilder {
Method method;
Class<?> instanceClass;
public CacheKey(Method method, Class<?> instanceClass) {
CacheKey(Method method, Class<?> instanceClass) {
super();
this.method = method;
this.instanceClass = instanceClass;
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;
@ -81,14 +82,14 @@ public class ProxyBuilder {
}
private static final ConcurrentMap<CacheKey, Method> methodsMapping = new ConcurrentHashMap<CacheKey, Method>();
private static final ConcurrentMap<CacheKey, Method> METHODS_MAPPING = new ConcurrentHashMap<CacheKey, Method>();
public static <T> T create(final Callback commandExecutor, final Object instance, final Object implementation, final Class<T> clazz) {
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, final Object[] args) throws Throwable {
CacheKey key = new CacheKey(method, instance.getClass());
Method instanceMethod = methodsMapping.get(key);
Method instanceMethod = METHODS_MAPPING.get(key);
if (instanceMethod == null) {
if (implementation != null) {
try {
@ -108,7 +109,7 @@ public class ProxyBuilder {
}
}
methodsMapping.put(key, instanceMethod);
METHODS_MAPPING.put(key, instanceMethod);
}
final Method mm = instanceMethod;
if (instanceMethod.getName().endsWith("Async")) {

@ -15,8 +15,6 @@
*/
package org.redisson.misc;
import java.util.function.BiConsumer;
import org.redisson.api.RFuture;
/**

@ -27,6 +27,7 @@ import java.util.concurrent.locks.AbstractQueuedSynchronizer;
* @author Manik Surtani (<a href="mailto:manik@jboss.org">manik@jboss.org</a>)
* @since 4.0
*/
@SuppressWarnings({"MultipleVariableDeclarations", "AvoidInlineConditionals", "UpperEll"})
public class ReclosableLatch extends AbstractQueuedSynchronizer {
private static final long serialVersionUID = 1744280161777661090l;

@ -34,12 +34,12 @@ import io.netty.util.concurrent.Promise;
*/
public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise<T> {
private static final Field listenersField;
private static final Field LISTENERS_FIELD;
static {
try {
listenersField = DefaultPromise.class.getDeclaredField("listeners");
listenersField.setAccessible(true);
LISTENERS_FIELD = DefaultPromise.class.getDeclaredField("listeners");
LISTENERS_FIELD.setAccessible(true);
} catch (Exception e) {
throw new IllegalStateException(e);
}
@ -165,7 +165,7 @@ public class RedissonPromise<T> extends CompletableFuture<T> implements RPromise
@Override
public boolean hasListeners() {
try {
return listenersField.get(promise) != null || getNumberOfDependents() > 0;
return LISTENERS_FIELD.get(promise) != null || getNumberOfDependents() > 0;
} catch (Exception e) {
throw new IllegalStateException(e);
}

@ -33,7 +33,7 @@ public class AsyncSemaphore {
private Runnable runnable;
private int permits;
public Entry(Runnable runnable, int permits) {
Entry(Runnable runnable, int permits) {
super();
this.runnable = runnable;
this.permits = permits;
@ -48,6 +48,7 @@ public class AsyncSemaphore {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;

@ -25,8 +25,8 @@ import org.redisson.misc.RPromise;
*/
public class LockPubSub extends PublishSubscribe<RedissonLockEntry> {
public static final Long unlockMessage = 0L;
public static final Long readUnlockMessage = 1L;
public static final Long UNLOCK_MESSAGE = 0L;
public static final Long READ_UNLOCK_MESSAGE = 1L;
@Override
protected RedissonLockEntry createEntry(RPromise<RedissonLockEntry> newPromise) {
@ -35,14 +35,14 @@ public class LockPubSub extends PublishSubscribe<RedissonLockEntry> {
@Override
protected void onMessage(RedissonLockEntry value, Long message) {
if (message.equals(unlockMessage)) {
if (message.equals(UNLOCK_MESSAGE)) {
Runnable runnableToExecute = value.getListeners().poll();
if (runnableToExecute != null) {
runnableToExecute.run();
}
value.getLatch().release();
} else if (message.equals(readUnlockMessage)) {
} else if (message.equals(READ_UNLOCK_MESSAGE)) {
while (true) {
Runnable runnableToExecute = value.getListeners().poll();
if (runnableToExecute == null) {

@ -112,13 +112,13 @@ public class PubSubConnectionEntry {
Queue<RedisPubSubListener<?>> listeners = channelListeners.get(channelName);
for (RedisPubSubListener<?> listener : listeners) {
if (listener instanceof PubSubMessageListener) {
if (((PubSubMessageListener)listener).getListener() == msgListener) {
if (((PubSubMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}
}
if (listener instanceof PubSubPatternMessageListener) {
if (((PubSubPatternMessageListener)listener).getListener() == msgListener) {
if (((PubSubPatternMessageListener<?>) listener).getListener() == msgListener) {
removeListener(channelName, listener);
return true;
}

@ -120,7 +120,7 @@ abstract class PublishSubscribe<E extends PubSubEntry<E>> {
return;
}
PublishSubscribe.this.onMessage(value, (Long)message);
PublishSubscribe.this.onMessage(value, (Long) message);
}
@Override

@ -245,7 +245,7 @@ public class PublishSubscribeService {
RFuture<RedisPubSubConnection> connFuture = nextPubSubConnection(slot);
promise.onComplete((res, e) -> {
if (e != null) {
((RPromise<RedisPubSubConnection>)connFuture).tryFailure(e);
((RPromise<RedisPubSubConnection>) connFuture).tryFailure(e);
}
});
connFuture.onComplete((conn, e) -> {

@ -115,8 +115,8 @@ public class MapReactiveIterator<K, V, M> implements Consumer<FluxSink<M>> {
return false;
}
M getValue(final Entry<Object, Object> entry) {
return (M)new AbstractMap.SimpleEntry<K, V>((K)entry.getKey(), (V)entry.getValue()) {
M getValue(Entry<Object, Object> entry) {
return (M) new AbstractMap.SimpleEntry<K, V>((K) entry.getKey(), (V) entry.getValue()) {
@Override
public V setValue(V value) {

@ -33,10 +33,10 @@ public class ReactiveProxyBuilder {
return create(commandExecutor, instance, null, clazz);
}
public static <T> T create(final CommandReactiveExecutor commandExecutor, Object instance, Object implementation, Class<T> clazz) {
public static <T> T create(CommandReactiveExecutor commandExecutor, Object instance, Object implementation, Class<T> clazz) {
return ProxyBuilder.create(new Callback() {
@Override
public Object execute(final Method mm, final Object instance, final Object[] args) {
public Object execute(Method mm, Object instance, Object[] args) {
return commandExecutor.reactive(new Supplier<RFuture<Object>>() {
@Override
public RFuture<Object> get() {

@ -34,7 +34,7 @@ public class RedissonBlockingQueueReactive<V> extends RedissonListReactive<V> {
private final RBlockingQueue<V> queue;
public RedissonBlockingQueueReactive(RBlockingQueue<V> queue) {
super((RListAsync<V>)queue);
super((RListAsync<V>) queue);
this.queue = queue;
}

@ -86,7 +86,7 @@ public class RedissonKeysReactive {
client = res.getRedisClient();
long prevIterPos = nextIterPos;
if (nextIterPos == 0 && firstValues == null) {
firstValues = (List<String>)(Object)res.getValues();
firstValues = (List<String>) (Object) res.getValues();
} else if (res.getValues().equals(firstValues)) {
emitter.complete();
currentIndex = 0;
@ -98,7 +98,7 @@ public class RedissonKeysReactive {
nextIterPos = -1;
}
for (Object val : res.getValues()) {
emitter.next((String)val);
emitter.next((String) val);
currentIndex--;
if (currentIndex == 0) {
emitter.complete();

@ -42,7 +42,7 @@ public class RedissonLexSortedSetReactive {
return new PublisherAdder<String>() {
@Override
public RFuture<Boolean> add(Object e) {
return instance.addAsync((String)e);
return instance.addAsync((String) e);
}
}.addAll(c);
}
@ -51,7 +51,7 @@ public class RedissonLexSortedSetReactive {
return Flux.create(new SetReactiveIterator<String>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
return ((RedissonScoredSortedSet<String>)instance).scanIteratorAsync(client, nextIterPos, pattern, count);
return ((RedissonScoredSortedSet<String>) instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
});
}

@ -15,10 +15,6 @@
*/
package org.redisson.reactive;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonListMultimap;
import org.redisson.api.RList;
import org.redisson.api.RListMultimap;
@ -34,21 +30,23 @@ import org.redisson.client.codec.Codec;
*/
public class RedissonListMultimapReactive<K, V> {
private CommandReactiveExecutor commandExecutor;
private RedissonListMultimap<K, V> instance;
private final CommandReactiveExecutor commandExecutor;
private final RedissonListMultimap<K, V> instance;
public RedissonListMultimapReactive(CommandReactiveExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RedissonListMultimapReactive(Codec codec, CommandReactiveExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(codec, commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RListReactive<V> get(K key) {
RList<V> list = ((RListMultimap<K, V>)instance).get(key);
RList<V> list = ((RListMultimap<K, V>) instance).get(key);
return ReactiveProxyBuilder.create(commandExecutor, instance,
new RedissonListReactive<V>(instance.getCodec(), commandExecutor, list.getName()), RListReactive.class);
}
}
}

@ -118,7 +118,7 @@ public class RedissonListReactive<V> {
@Override
public RFuture<Boolean> add(Object o) {
return instance.addAsync((V)o);
return instance.addAsync((V) o);
}
}.addAll(c);

@ -17,16 +17,12 @@ package org.redisson.reactive;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonMap;
import org.redisson.api.RMapCache;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
*

@ -17,9 +17,6 @@ package org.redisson.reactive;
import java.util.Map;
import java.util.Map.Entry;
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonMap;
@ -31,7 +28,6 @@ import org.redisson.api.RSemaphoreReactive;
import org.redisson.api.RedissonReactiveClient;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
* Distributed and concurrent implementation of {@link java.util.concurrent.ConcurrentMap}
@ -111,27 +107,27 @@ public class RedissonMapReactive<K, V> {
}
public RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "permitexpirablesemaphore");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreReactive getSemaphore(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "semaphore");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "semaphore");
return redisson.getSemaphore(name);
}
public RLockReactive getFairLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "fairlock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockReactive getReadWriteLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "rw_lock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockReactive getLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "lock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "lock");
return redisson.getLock(name);
}

@ -70,17 +70,17 @@ public class RedissonScoredSortedSetReactive<V> {
});
}
private Flux<V> scanIteratorReactive(final String pattern, final int count) {
private Flux<V> scanIteratorReactive(String pattern, int count) {
return Flux.create(new SetReactiveIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
return ((RedissonScoredSortedSet<V>)instance).scanIteratorAsync(client, nextIterPos, pattern, count);
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<V>) instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
});
}
public String getName() {
return ((RedissonScoredSortedSet<V>)instance).getName();
return ((RedissonScoredSortedSet<V>) instance).getName();
}
public Flux<V> iterator() {

@ -15,12 +15,6 @@
*/
package org.redisson.reactive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonSetCache;
import org.redisson.ScanIterator;
@ -34,9 +28,7 @@ import org.redisson.api.RedissonReactiveClient;
import org.redisson.client.RedisClient;
import org.redisson.client.protocol.decoder.ListScanResult;
import io.netty.buffer.ByteBuf;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
/**
*
@ -58,7 +50,7 @@ public class RedissonSetCacheReactive<V> {
return Flux.create(new SetReactiveIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((ScanIterator)instance).scanIteratorAsync(instance.getName(), client, nextIterPos, null, 10);
return ((ScanIterator) instance).scanIteratorAsync(instance.getName(), client, nextIterPos, null, 10);
}
});
}
@ -67,33 +59,33 @@ public class RedissonSetCacheReactive<V> {
return new PublisherAdder<V>() {
@Override
public RFuture<Boolean> add(Object o) {
return instance.addAsync((V)o);
return instance.addAsync((V) o);
}
}.addAll(c);
}
public RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "permitexpirablesemaphore");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreReactive getSemaphore(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "semaphore");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "semaphore");
return redisson.getSemaphore(name);
}
public RLockReactive getFairLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "fairlock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockReactive getReadWriteLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "rw_lock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockReactive getLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "lock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "lock");
return redisson.getLock(name);
}

@ -48,7 +48,7 @@ public class RedissonSetMultimapReactive<K, V> {
}
public RSetReactive<V> get(K key) {
RSet<V> set = ((RSetMultimap<K, V>)instance).get(key);
RSet<V> set = ((RSetMultimap<K, V>) instance).get(key);
return ReactiveProxyBuilder.create(commandExecutor, set,
new RedissonSetReactive<V>(set, redisson), RSetReactive.class);
}

@ -15,12 +15,6 @@
*/
package org.redisson.reactive;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.function.Supplier;
import org.reactivestreams.Publisher;
import org.redisson.RedissonSet;
import org.redisson.api.RFuture;
@ -56,7 +50,7 @@ public class RedissonSetReactive<V> {
return new PublisherAdder<Object>() {
@Override
public RFuture<Boolean> add(Object e) {
return instance.addAsync((V)e);
return instance.addAsync((V) e);
}
}.addAll(c);
}
@ -69,11 +63,11 @@ public class RedissonSetReactive<V> {
return iterator(pattern, 10);
}
public Publisher<V> iterator(final String pattern, final int count) {
public Publisher<V> iterator(String pattern, int count) {
return Flux.create(new SetReactiveIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonSet)instance).scanIteratorAsync(instance.getName(), client, nextIterPos, pattern, count);
return ((RedissonSet) instance).scanIteratorAsync(instance.getName(), client, nextIterPos, pattern, count);
}
});
}
@ -83,27 +77,27 @@ public class RedissonSetReactive<V> {
}
public RPermitExpirableSemaphoreReactive getPermitExpirableSemaphore(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "permitexpirablesemaphore");
String name = ((RedissonSet<V>) instance).getLockName(value, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreReactive getSemaphore(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "semaphore");
String name = ((RedissonSet<V>) instance).getLockName(value, "semaphore");
return redisson.getSemaphore(name);
}
public RLockReactive getFairLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "fairlock");
String name = ((RedissonSet<V>) instance).getLockName(value, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockReactive getReadWriteLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "rw_lock");
String name = ((RedissonSet<V>) instance).getLockName(value, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockReactive getLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "lock");
String name = ((RedissonSet<V>) instance).getLockName(value, "lock");
return redisson.getLock(name);
}

@ -71,7 +71,7 @@ public abstract class SetReactiveIterator<V> implements Consumer<FluxSink<V>> {
nextIterPos = res.getPos();
for (Object val : res.getValues()) {
emitter.next((V)val);
emitter.next((V) val);
elementsRead.incrementAndGet();
}

@ -15,8 +15,6 @@
*/
package org.redisson.remote;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ -51,6 +49,7 @@ public class RemoteServiceKey {
}
@Override
@SuppressWarnings("AvoidInlineConditionals")
public int hashCode() {
final int prime = 31;
int result = 1;
@ -76,7 +75,7 @@ public class RemoteServiceKey {
return false;
} else if (!signatures.equals(other.signatures)) {
return false;
} if (serviceInterface == null) {
} else if (serviceInterface == null) {
if (other.serviceInterface != null)
return false;
} else if (!serviceInterface.equals(other.serviceInterface))

@ -20,7 +20,6 @@ import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import org.reactivestreams.Publisher;
import org.reactivestreams.Subscription;
import org.redisson.api.BatchOptions;
import org.redisson.api.BatchResult;
import org.redisson.api.RFuture;

@ -15,10 +15,7 @@
*/
package org.redisson.rx;
import java.util.concurrent.Callable;
import org.redisson.RedissonBlockingDeque;
import org.redisson.api.RFuture;
import io.reactivex.Flowable;

@ -15,10 +15,7 @@
*/
package org.redisson.rx;
import java.util.concurrent.Callable;
import org.redisson.api.RBlockingQueueAsync;
import org.redisson.api.RFuture;
import org.redisson.api.RListAsync;
import io.reactivex.Flowable;

@ -35,7 +35,6 @@ import io.reactivex.processors.ReplayProcessor;
public class RedissonKeysRx {
private final CommandRxExecutor commandExecutor;
private final RedissonKeys instance;
public RedissonKeysRx(CommandRxExecutor commandExecutor) {
@ -81,7 +80,7 @@ public class RedissonKeysRx {
client = res.getRedisClient();
long prevIterPos = nextIterPos;
if (nextIterPos == 0 && firstValues == null) {
firstValues = (List<String>)(Object)res.getValues();
firstValues = (List<String>) (Object) res.getValues();
} else if (res.getValues().equals(firstValues)) {
p.onComplete();
currentIndex = 0;
@ -93,7 +92,7 @@ public class RedissonKeysRx {
nextIterPos = -1;
}
for (Object val : res.getValues()) {
p.onNext((String)val);
p.onNext((String) val);
currentIndex--;
if (currentIndex == 0) {
p.onComplete();

@ -41,15 +41,15 @@ public class RedissonLexSortedSetRx {
return new PublisherAdder<String>() {
@Override
public RFuture<Boolean> add(Object e) {
return instance.addAsync((String)e);
return instance.addAsync((String) e);
}
}.addAll(c);
}
private Flowable<String> scanIteratorReactive(final String pattern, final int count) {
private Flowable<String> scanIteratorReactive(String pattern, int count) {
return new SetRxIterator<String>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<String>)instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
}.create();

@ -30,19 +30,21 @@ import org.redisson.client.codec.Codec;
*/
public class RedissonListMultimapRx<K, V> {
private CommandRxExecutor commandExecutor;
private RedissonListMultimap<K, V> instance;
private final CommandRxExecutor commandExecutor;
private final RedissonListMultimap<K, V> instance;
public RedissonListMultimapRx(CommandRxExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RedissonListMultimapRx(Codec codec, CommandRxExecutor commandExecutor, String name) {
this.instance = new RedissonListMultimap<K, V>(codec, commandExecutor, name);
this.commandExecutor = commandExecutor;
}
public RListRx<V> get(K key) {
RedissonList<V> list = (RedissonList<V>) ((RListMultimap<K, V>)instance).get(key);
RedissonList<V> list = (RedissonList<V>) ((RListMultimap<K, V>) instance).get(key);
return RxProxyBuilder.create(commandExecutor, instance,
new RedissonListRx<V>(list), RListRx.class);
}

@ -98,7 +98,7 @@ public class RedissonListRx<V> {
@Override
public RFuture<Boolean> add(Object o) {
return instance.addAsync((V)o);
return instance.addAsync((V) o);
}
}.addAll(c);

@ -40,7 +40,7 @@ import org.redisson.api.RedissonRxClient;
public class RedissonMapRx<K, V> {
private final RedissonMap<K, V> instance;
private RedissonRxClient redisson;
private final RedissonRxClient redisson;
public RedissonMapRx(RMap<K, V> instance, RedissonRx redisson) {
this.instance = (RedissonMap<K, V>) instance;
@ -106,27 +106,27 @@ public class RedissonMapRx<K, V> {
}
public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "permitexpirablesemaphore");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreRx getSemaphore(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "semaphore");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "semaphore");
return redisson.getSemaphore(name);
}
public RLockRx getFairLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "fairlock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockRx getReadWriteLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "rw_lock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockRx getLock(K key) {
String name = ((RedissonMap<K, V>)instance).getLockName(key, "lock");
String name = ((RedissonMap<K, V>) instance).getLockName(key, "lock");
return redisson.getLock(name);
}

@ -115,7 +115,7 @@ public class RedissonMapRxIterator<K, V, M> {
}
M getValue(Entry<Object, Object> entry) {
return (M)new AbstractMap.SimpleEntry<K, V>((K)entry.getKey(), (V)entry.getValue()) {
return (M) new AbstractMap.SimpleEntry<K, V>((K) entry.getKey(), (V) entry.getValue()) {
@Override
public V setValue(V value) {

@ -17,6 +17,7 @@ package org.redisson.rx;
import org.redisson.RedissonScoredSortedSet;
import org.redisson.api.RFuture;
import org.redisson.api.RObject;
import org.redisson.api.RScoredSortedSetAsync;
import org.redisson.client.RedisClient;
import org.redisson.client.protocol.decoder.ListScanResult;
@ -37,11 +38,11 @@ public class RedissonScoredSortedSetRx<V> {
this.instance = instance;
}
private Flowable<V> scanIteratorReactive(final String pattern, final int count) {
private Flowable<V> scanIteratorReactive(String pattern, int count) {
return new SetRxIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(final RedisClient client, final long nextIterPos) {
return ((RedissonScoredSortedSet<V>)instance).scanIteratorAsync(client, nextIterPos, pattern, count);
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonScoredSortedSet<V>) instance).scanIteratorAsync(client, nextIterPos, pattern, count);
}
}.create();
}
@ -59,7 +60,7 @@ public class RedissonScoredSortedSetRx<V> {
}
public String getName() {
return ((RedissonScoredSortedSet<V>)instance).getName();
return ((RObject) instance).getName();
}
public Flowable<V> iterator() {

@ -48,7 +48,7 @@ public class RedissonSetCacheRx<V> {
return new SetRxIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((ScanIterator)instance).scanIteratorAsync(instance.getName(), client, nextIterPos, null, 10);
return ((ScanIterator) instance).scanIteratorAsync(instance.getName(), client, nextIterPos, null, 10);
}
}.create();
}
@ -57,33 +57,33 @@ public class RedissonSetCacheRx<V> {
return new PublisherAdder<V>() {
@Override
public RFuture<Boolean> add(Object o) {
return instance.addAsync((V)o);
return instance.addAsync((V) o);
}
}.addAll(c);
}
public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "permitexpirablesemaphore");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreRx getSemaphore(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "semaphore");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "semaphore");
return redisson.getSemaphore(name);
}
public RLockRx getFairLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "fairlock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockRx getReadWriteLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "rw_lock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockRx getLock(V value) {
String name = ((RedissonSetCache<V>)instance).getLockName(value, "lock");
String name = ((RedissonSetCache<V>) instance).getLockName(value, "lock");
return redisson.getLock(name);
}

@ -48,7 +48,7 @@ public class RedissonSetMultimapRx<K, V> {
}
public RSetRx<V> get(K key) {
RedissonSet<V> set = (RedissonSet<V>) ((RSetMultimap<K, V>)instance).get(key);
RedissonSet<V> set = (RedissonSet<V>) ((RSetMultimap<K, V>) instance).get(key);
return RxProxyBuilder.create(commandExecutor, set,
new RedissonSetRx<V>(set, redisson), RSetRx.class);
}

@ -50,7 +50,7 @@ public class RedissonSetRx<V> {
return new PublisherAdder<Object>() {
@Override
public RFuture<Boolean> add(Object e) {
return instance.addAsync((V)e);
return instance.addAsync((V) e);
}
}.addAll(c);
}
@ -63,11 +63,11 @@ public class RedissonSetRx<V> {
return iterator(pattern, 10);
}
public Flowable<V> iterator(final String pattern, final int count) {
public Flowable<V> iterator(String pattern, int count) {
return new SetRxIterator<V>() {
@Override
protected RFuture<ListScanResult<Object>> scanIterator(RedisClient client, long nextIterPos) {
return ((RedissonSet<V>)instance).scanIteratorAsync(instance.getName(), client, nextIterPos, pattern, count);
return ((RedissonSet<V>) instance).scanIteratorAsync(instance.getName(), client, nextIterPos, pattern, count);
}
}.create();
}
@ -77,27 +77,27 @@ public class RedissonSetRx<V> {
}
public RPermitExpirableSemaphoreRx getPermitExpirableSemaphore(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "permitexpirablesemaphore");
String name = ((RedissonSet<V>) instance).getLockName(value, "permitexpirablesemaphore");
return redisson.getPermitExpirableSemaphore(name);
}
public RSemaphoreRx getSemaphore(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "semaphore");
String name = ((RedissonSet<V>) instance).getLockName(value, "semaphore");
return redisson.getSemaphore(name);
}
public RLockRx getFairLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "fairlock");
String name = ((RedissonSet<V>) instance).getLockName(value, "fairlock");
return redisson.getFairLock(name);
}
public RReadWriteLockRx getReadWriteLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "rw_lock");
String name = ((RedissonSet<V>) instance).getLockName(value, "rw_lock");
return redisson.getReadWriteLock(name);
}
public RLockRx getLock(V value) {
String name = ((RedissonSet<V>)instance).getLockName(value, "lock");
String name = ((RedissonSet<V>) instance).getLockName(value, "lock");
return redisson.getLock(name);
}

@ -71,7 +71,7 @@ public abstract class SetRxIterator<V> {
nextIterPos = res.getPos();
for (Object val : res.getValues()) {
p.onNext((V)val);
p.onNext((V) val);
elementsRead.incrementAndGet();
}

Loading…
Cancel
Save