refactoring

pull/6077/head
Nikita Koksharov 8 months ago
parent bdcd3cff75
commit 1911133b3b

@ -170,11 +170,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V merge(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
checkValue(value);
@ -202,11 +198,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> mergeAsync(K key, V value, BiFunction<? super V, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
checkValue(value);
@ -241,12 +233,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -278,11 +265,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V compute(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -308,11 +291,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeIfAbsentAsync(K key, Function<? super K, ? extends V> mappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(mappingFunction);
@ -344,11 +323,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V computeIfAbsent(K key, Function<? super K, ? extends V> mappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(mappingFunction);
@ -373,11 +348,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public RFuture<V> computeIfPresentAsync(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(remappingFunction);
@ -409,11 +380,7 @@ public class RedissonMap<K, V> extends RedissonExpirable implements RMap<K, V> {
@Override
public V computeIfPresent(K key, BiFunction<? super K, ? super V, ? extends V> remappingFunction) {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
checkNotBatch();
checkKey(key);
Objects.requireNonNull(remappingFunction);

@ -151,6 +151,18 @@ public abstract class RedissonObject implements RObject {
return get(sizeInMemoryAsync());
}
protected final String mapName(String name) {
return commandExecutor.getServiceManager().getConfig().getNameMapper().map(name);
}
protected final void checkNotBatch() {
if (commandExecutor instanceof CommandBatchService
|| commandExecutor instanceof CommandReactiveBatchService
|| commandExecutor instanceof CommandRxBatchService) {
throw new IllegalStateException("This method doesn't work in batch mode.");
}
}
@Override
public RFuture<Void> renameAsync(String newName) {
RFuture<Void> future = commandExecutor.writeAsync(getRawName(), StringCodec.INSTANCE, RedisCommands.RENAME, getRawName(), newName);

Loading…
Cancel
Save