diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java index 1752cb21ad..bb36033aa9 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterConnection.java @@ -435,20 +435,11 @@ public void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode) { RedisClusterNode nodeToUse = topologyProvider.getTopology().lookup(node); String nodeId = nodeToUse.getId(); - clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback) client -> { - - switch (mode) { - case IMPORTING: - return client.clusterSetSlotImporting(slot, nodeId); - case MIGRATING: - return client.clusterSetSlotMigrating(slot, nodeId); - case STABLE: - return client.clusterSetSlotStable(slot); - case NODE: - return client.clusterSetSlotNode(slot, nodeId); - } - - throw new IllegalArgumentException(String.format("Unknown AddSlots mode '%s'", mode)); + clusterCommandExecutor.executeCommandOnSingleNode((JedisClusterCommandCallback) client -> switch (mode) { + case IMPORTING -> client.clusterSetSlotImporting(slot, nodeId); + case MIGRATING -> client.clusterSetSlotMigrating(slot, nodeId); + case STABLE -> client.clusterSetSlotStable(slot); + case NODE -> client.clusterSetSlotNode(slot, nodeId); }, node); } diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java index ef746d039c..3fdce40c96 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisConverters.java @@ -288,18 +288,12 @@ public static SortingParams toSortingParams(@Nullable SortParameters params) { } public static BitOP toBitOp(BitOperation bitOp) { - switch (bitOp) { - case AND: - return BitOP.AND; - case OR: - return BitOP.OR; - case NOT: - return BitOP.NOT; - case XOR: - return BitOP.XOR; - default: - throw new IllegalArgumentException(); - } + return switch (bitOp) { + case AND -> BitOP.AND; + case OR -> BitOP.OR; + case NOT -> BitOP.NOT; + case XOR -> BitOP.XOR; + }; } /** @@ -462,14 +456,11 @@ public static SetParams toSetCommandNxXxArgument(SetOption option, SetParams par SetParams paramsToUse = params == null ? SetParams.setParams() : params; - switch (option) { - case SET_IF_PRESENT: - return paramsToUse.xx(); - case SET_IF_ABSENT: - return paramsToUse.nx(); - default: - return paramsToUse; - } + return switch (option) { + case SET_IF_PRESENT -> paramsToUse.xx(); + case SET_IF_ABSENT -> paramsToUse.nx(); + default -> paramsToUse; + }; } private static byte[] boundaryToBytes(org.springframework.data.domain.Range.Bound boundary, byte[] inclPrefix, @@ -663,24 +654,16 @@ public static GeoRadiusParam toGeoRadiusParam(GeoRadiusCommandArgs source) { if (source.hasFlags()) { for (Flag flag : source.getFlags()) { switch (flag) { - case WITHCOORD: - param.withCoord(); - break; - case WITHDIST: - param.withDist(); - break; + case WITHCOORD -> param.withCoord(); + case WITHDIST -> param.withDist(); } } } if (source.hasSortDirection()) { switch (source.getSortDirection()) { - case ASC: - param.sortAscending(); - break; - case DESC: - param.sortDescending(); - break; + case ASC -> param.sortAscending(); + case DESC -> param.sortDescending(); } } @@ -702,12 +685,12 @@ public static GeoRadiusParam toGeoRadiusParam(GeoRadiusCommandArgs source) { static double toSeconds(long timeout, TimeUnit unit) { switch (unit) { - case MILLISECONDS: - case MICROSECONDS: - case NANOSECONDS: + case MILLISECONDS, MICROSECONDS, NANOSECONDS -> { return unit.toMillis(timeout) / 1000d; - default: + } + default -> { return unit.toSeconds(timeout); + } } } @@ -753,14 +736,10 @@ static FlushMode toFlushMode(@Nullable RedisServerCommands.FlushOption option) { return FlushMode.SYNC; } - switch (option) { - case ASYNC: - return FlushMode.ASYNC; - case SYNC: - return FlushMode.SYNC; - default: - throw new IllegalArgumentException("Flush option " + option + " is not supported"); - } + return switch (option) { + case ASYNC -> FlushMode.ASYNC; + case SYNC -> FlushMode.SYNC; + }; } static GeoSearchParam toGeoSearchParams(GeoReference reference, GeoShape predicate, diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnection.java index f3bd214bf2..2a3ba2c83b 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceClusterConnection.java @@ -419,19 +419,11 @@ public void clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode) { RedisClusterNode nodeToUse = topologyProvider.getTopology().lookup(node); String nodeId = nodeToUse.getId(); - clusterCommandExecutor.executeCommandOnSingleNode((LettuceClusterCommandCallback) client -> { - switch (mode) { - case MIGRATING: - return client.clusterSetSlotMigrating(slot, nodeId); - case IMPORTING: - return client.clusterSetSlotImporting(slot, nodeId); - case NODE: - return client.clusterSetSlotNode(slot, nodeId); - case STABLE: - return client.clusterSetSlotStable(slot); - default: - throw new InvalidDataAccessApiUsageException("Invalid import mode for cluster slot: " + slot); - } + clusterCommandExecutor.executeCommandOnSingleNode((LettuceClusterCommandCallback) client -> switch (mode) { + case MIGRATING -> client.clusterSetSlotMigrating(slot, nodeId); + case IMPORTING -> client.clusterSetSlotImporting(slot, nodeId); + case NODE -> client.clusterSetSlotNode(slot, nodeId); + case STABLE -> client.clusterSetSlotStable(slot); }, node); } diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java index 7b00092cba..cb5ba59ba9 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConverters.java @@ -175,20 +175,15 @@ public static String toString(@Nullable byte[] source) { public static ScriptOutputType toScriptOutputType(ReturnType returnType) { - switch (returnType) { - case BOOLEAN: - return ScriptOutputType.BOOLEAN; - case MULTI: - return ScriptOutputType.MULTI; - case VALUE: - return ScriptOutputType.VALUE; - case INTEGER: - return ScriptOutputType.INTEGER; - case STATUS: - return ScriptOutputType.STATUS; - default: + return switch (returnType) { + case BOOLEAN -> ScriptOutputType.BOOLEAN; + case MULTI -> ScriptOutputType.MULTI; + case VALUE -> ScriptOutputType.VALUE; + case INTEGER -> ScriptOutputType.INTEGER; + case STATUS -> ScriptOutputType.STATUS; + default -> throw new IllegalArgumentException("Return type " + returnType + " is not a supported script output type"); - } + }; } public static boolean toBoolean(Position where) { @@ -514,31 +509,14 @@ private static Set parseFlags(@Nullable Set source) { Set flags = new LinkedHashSet<>(source != null ? source.size() : 8, 1); for (NodeFlag flag : source) { switch (flag) { - case NOFLAGS: - flags.add(Flag.NOFLAGS); - break; - case EVENTUAL_FAIL: - flags.add(Flag.PFAIL); - break; - case FAIL: - flags.add(Flag.FAIL); - break; - case HANDSHAKE: - flags.add(Flag.HANDSHAKE); - break; - case MASTER: - flags.add(Flag.MASTER); - break; - case MYSELF: - flags.add(Flag.MYSELF); - break; - case NOADDR: - flags.add(Flag.NOADDR); - break; - case SLAVE: - case REPLICA: - flags.add(Flag.REPLICA); - break; + case NOFLAGS -> flags.add(Flag.NOFLAGS); + case EVENTUAL_FAIL -> flags.add(Flag.PFAIL); + case FAIL -> flags.add(Flag.FAIL); + case HANDSHAKE -> flags.add(Flag.HANDSHAKE); + case MASTER -> flags.add(Flag.MASTER); + case MYSELF -> flags.add(Flag.MYSELF); + case NOADDR -> flags.add(Flag.NOADDR); + case SLAVE, REPLICA -> flags.add(Flag.REPLICA); } } return flags; @@ -562,20 +540,20 @@ public static SetArgs toSetArgs(@Nullable Expiration expiration, @Nullable SetOp } else if (!expiration.isPersistent()) { switch (expiration.getTimeUnit()) { - case MILLISECONDS: + case MILLISECONDS -> { if (expiration.isUnixTimestamp()) { args.pxAt(expiration.getConverted(TimeUnit.MILLISECONDS)); } else { args.px(expiration.getConverted(TimeUnit.MILLISECONDS)); } - break; - default: + } + default -> { if (expiration.isUnixTimestamp()) { args.exAt(expiration.getConverted(TimeUnit.SECONDS)); } else { args.ex(expiration.getConverted(TimeUnit.SECONDS)); } - break; + } } } } @@ -583,14 +561,8 @@ public static SetArgs toSetArgs(@Nullable Expiration expiration, @Nullable SetOp if (option != null) { switch (option) { - case SET_IF_ABSENT: - args.nx(); - break; - case SET_IF_PRESENT: - args.xx(); - break; - default: - break; + case SET_IF_ABSENT -> args.nx(); + case SET_IF_PRESENT -> args.xx(); } } return args; @@ -686,12 +658,8 @@ public static GeoArgs toGeoArgs(GeoCommandArgs args) { if (args.hasSortDirection()) { switch (args.getSortDirection()) { - case ASC: - geoArgs.asc(); - break; - case DESC: - geoArgs.desc(); - break; + case ASC -> geoArgs.asc(); + case DESC -> geoArgs.desc(); } } @@ -735,23 +703,12 @@ public static BitFieldArgs toBitFieldArgs(BitFieldSubCommands subCommands) { BitFieldIncrBy.Overflow overflow = ((BitFieldIncrBy) subCommand).getOverflow(); if (overflow != null) { - BitFieldArgs.OverflowType type; - - switch (overflow) { - case SAT: - type = BitFieldArgs.OverflowType.SAT; - break; - case FAIL: - type = BitFieldArgs.OverflowType.FAIL; - break; - case WRAP: - type = BitFieldArgs.OverflowType.WRAP; - break; - default: - throw new IllegalArgumentException( - String.format("Invalid OVERFLOW; Expected one the following %s but got %s", - Arrays.toString(Overflow.values()), overflow)); - } + BitFieldArgs.OverflowType type = switch (overflow) { + case SAT -> BitFieldArgs.OverflowType.SAT; + case FAIL -> BitFieldArgs.OverflowType.FAIL; + case WRAP -> BitFieldArgs.OverflowType.WRAP; + }; + args = args.overflow(type); } @@ -937,14 +894,10 @@ static FlushMode toFlushMode(@Nullable RedisServerCommands.FlushOption option) { return FlushMode.SYNC; } - switch (option) { - case ASYNC: - return FlushMode.ASYNC; - case SYNC: - return FlushMode.SYNC; - default: - throw new IllegalArgumentException("Flush option " + option + " is not supported"); - } + return switch (option) { + case ASYNC -> FlushMode.ASYNC; + case SYNC -> FlushMode.SYNC; + }; } /** diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisClusterConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisClusterConnection.java index 003276bae4..aa8c9ce011 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisClusterConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveRedisClusterConnection.java @@ -283,18 +283,12 @@ public Mono clusterSetSlot(RedisClusterNode node, int slot, AddSlots mode) RedisClusterNode nodeToUse = lookup(node); String nodeId = nodeToUse.getId(); - switch (mode) { - case MIGRATING: - return cmd.clusterSetSlotMigrating(slot, nodeId); - case IMPORTING: - return cmd.clusterSetSlotImporting(slot, nodeId); - case NODE: - return cmd.clusterSetSlotNode(slot, nodeId); - case STABLE: - return cmd.clusterSetSlotStable(slot); - default: - throw new InvalidDataAccessApiUsageException("Invalid import mode for cluster slot: " + slot); - } + return switch (mode) { + case MIGRATING -> cmd.clusterSetSlotMigrating(slot, nodeId); + case IMPORTING -> cmd.clusterSetSlotImporting(slot, nodeId); + case NODE -> cmd.clusterSetSlotNode(slot, nodeId); + case STABLE -> cmd.clusterSetSlotStable(slot); + }; }).then(); } @@ -359,12 +353,11 @@ protected Mono> getCommands protected Mono> getCommands(RedisNode node) { if (StringUtils.hasText(node.getId())) { - return getConnection().cast(StatefulRedisClusterConnection.class) - .flatMap(it -> { - StatefulRedisClusterConnection connection = it; - return Mono.fromCompletionStage(connection.getConnectionAsync(node.getId())) - .map(StatefulRedisConnection::reactive); - }); + return getConnection().cast(StatefulRedisClusterConnection.class).flatMap(it -> { + StatefulRedisClusterConnection connection = it; + return Mono.fromCompletionStage(connection.getConnectionAsync(node.getId())) + .map(StatefulRedisConnection::reactive); + }); } return getConnection().flatMap(it -> Mono.fromCompletionStage(it.getConnectionAsync(node.getHost(), node.getPort())) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommands.java index 59646357c5..180f5e63cf 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveStringCommands.java @@ -329,25 +329,16 @@ public Flux> bitOp(Publisher c ByteBuffer destinationKey = command.getDestinationKey(); ByteBuffer[] sourceKeys = command.getKeys().toArray(new ByteBuffer[0]); - switch (command.getBitOp()) { - case AND: - result = cmd.bitopAnd(destinationKey, sourceKeys); - break; - case OR: - result = cmd.bitopOr(destinationKey, sourceKeys); - break; - case XOR: - result = cmd.bitopXor(destinationKey, sourceKeys); - break; - case NOT: - + result = switch (command.getBitOp()) { + case AND -> cmd.bitopAnd(destinationKey, sourceKeys); + case OR -> cmd.bitopOr(destinationKey, sourceKeys); + case XOR -> cmd.bitopXor(destinationKey, sourceKeys); + case NOT -> { Assert.isTrue(sourceKeys.length == 1, "BITOP NOT does not allow more than 1 source key."); - - result = cmd.bitopNot(destinationKey, sourceKeys[0]); - break; - default: - throw new IllegalArgumentException(String.format("Unknown BITOP '%s'.", command.getBitOp())); - } + yield cmd.bitopNot(destinationKey, sourceKeys[0]); + } + default -> throw new IllegalArgumentException(String.format("Unknown BITOP '%s'.", command.getBitOp())); + }; return result.map(value -> new NumericResponse<>(command, value)); })); diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java index 4d6a712905..0340b2a761 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveZSetCommands.java @@ -703,15 +703,9 @@ private static ZStoreArgs zStoreArgs(@Nullable Aggregate aggregate, @Nullable Li ZStoreArgs args = new ZStoreArgs(); if (aggregate != null) { switch (aggregate) { - case MIN: - args.min(); - break; - case MAX: - args.max(); - break; - default: - args.sum(); - break; + case MIN -> args.min(); + case MAX -> args.max(); + default -> args.sum(); } } diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStringCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStringCommands.java index 3bce8d2ffb..16f96cd991 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStringCommands.java @@ -281,21 +281,17 @@ public Long bitOp(BitOperation op, byte[] destination, byte[]... keys) { return connection.invoke().just(it -> { - switch (op) { - case AND: - return it.bitopAnd(destination, keys); - case OR: - return it.bitopOr(destination, keys); - case XOR: - return it.bitopXor(destination, keys); - case NOT: + return switch (op) { + case AND -> it.bitopAnd(destination, keys); + case OR -> it.bitopOr(destination, keys); + case XOR -> it.bitopXor(destination, keys); + case NOT -> { if (keys.length != 1) { throw new IllegalArgumentException("Bitop NOT should only be performed against one key"); } - return it.bitopNot(destination, keys[0]); - default: - throw new UnsupportedOperationException("Bit operation " + op + " is not supported"); - } + yield it.bitopNot(destination, keys[0]); + } + }; }); } diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java index 488d91f7f2..8929abc8a4 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceZSetCommands.java @@ -703,15 +703,9 @@ private static ZStoreArgs zStoreArgs(@Nullable Aggregate aggregate, Weights weig if (aggregate != null) { switch (aggregate) { - case MIN: - args.min(); - break; - case MAX: - args.max(); - break; - default: - args.sum(); - break; + case MIN -> args.min(); + case MAX -> args.max(); + default -> args.sum(); } } @@ -726,15 +720,9 @@ private static ZAggregateArgs zAggregateArgs(@Nullable Aggregate aggregate, Weig if (aggregate != null) { switch (aggregate) { - case MIN: - args.min(); - break; - case MAX: - args.max(); - break; - default: - args.sum(); - break; + case MIN -> args.min(); + case MAX -> args.max(); + default -> args.sum(); } } diff --git a/src/main/java/org/springframework/data/redis/core/BoundOperationsProxyFactory.java b/src/main/java/org/springframework/data/redis/core/BoundOperationsProxyFactory.java index bb5933b64d..da23b36450 100644 --- a/src/main/java/org/springframework/data/redis/core/BoundOperationsProxyFactory.java +++ b/src/main/java/org/springframework/data/redis/core/BoundOperationsProxyFactory.java @@ -137,17 +137,14 @@ public Object invoke(MethodInvocation invocation) throws Throwable { Method method = invocation.getMethod(); - switch (method.getName()) { - case "getKey": - return delegate.getKey(); - - case "rename": + return switch (method.getName()) { + case "getKey" -> delegate.getKey(); + case "rename" -> { delegate.rename(invocation.getArguments()[0]); - return null; - - case "getOperations": - return delegate.getOps(); - } + yield null; + } + case "getOperations" -> delegate.getOps(); + }; if (method.getDeclaringClass() == boundOperationsInterface) { return doInvoke(invocation, method, operationsTarget, true); diff --git a/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java b/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java index 75b29c37d6..506b0f49ce 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java +++ b/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java @@ -412,14 +412,8 @@ public void afterCompletion(int status) { try { if (!readOnly) { switch (status) { - - case TransactionSynchronization.STATUS_COMMITTED: - connection.exec(); - break; - - case TransactionSynchronization.STATUS_ROLLED_BACK: - case TransactionSynchronization.STATUS_UNKNOWN: - default: + case TransactionSynchronization.STATUS_COMMITTED -> connection.exec(); + case TransactionSynchronization.STATUS_ROLLED_BACK, TransactionSynchronization.STATUS_UNKNOWN -> connection.discard(); } } @@ -445,8 +439,7 @@ public void afterCompletion(int status) { * @author Mark Paluch * @since 1.3 */ - static class ConnectionSplittingInterceptor - implements MethodInterceptor { + static class ConnectionSplittingInterceptor implements MethodInterceptor { private final RedisConnectionFactory factory; @@ -502,7 +495,6 @@ private Object invoke(Method method, Object target, Object[] args) throws Throwa } } - private boolean isPotentiallyThreadBoundCommand(RedisCommand command) { return RedisCommand.UNKNOWN.equals(command) || !command.isReadonly(); } @@ -607,8 +599,8 @@ public void clear() { * Subinterface of {@link RedisConnection} to be implemented by {@link RedisConnection} proxies. Allows access to the * underlying target {@link RedisConnection}. * - * @since 2.4.2 * @see RedisConnectionUtils#getTargetConnection(RedisConnection) + * @since 2.4.2 */ public interface RedisConnectionProxy extends RedisConnection, RawTargetAccess { diff --git a/src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java b/src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java index 876ee68bdb..51b232eacd 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java +++ b/src/main/java/org/springframework/data/redis/core/RedisKeyValueAdapter.java @@ -826,14 +826,11 @@ private boolean isKeyExpirationMessage(Message message) { private boolean keepShadowCopy() { - switch (shadowCopy) { - case OFF: - return false; - case ON: - return true; - default: - return this.expirationListener.get() != null; - } + return switch (shadowCopy) { + case OFF -> false; + case ON -> true; + default -> this.expirationListener.get() != null; + }; } /** diff --git a/src/main/java/org/springframework/data/redis/core/TimeoutUtils.java b/src/main/java/org/springframework/data/redis/core/TimeoutUtils.java index 8e9b6cbb58..0c8df5f6a9 100644 --- a/src/main/java/org/springframework/data/redis/core/TimeoutUtils.java +++ b/src/main/java/org/springframework/data/redis/core/TimeoutUtils.java @@ -76,14 +76,10 @@ public static long toSeconds(long timeout, TimeUnit unit) { */ public static double toDoubleSeconds(long timeout, TimeUnit unit) { - switch (unit) { - case MILLISECONDS: - case MICROSECONDS: - case NANOSECONDS: - return unit.toMillis(timeout) / 1000d; - default: - return unit.toSeconds(timeout); - } + return switch (unit) { + case MILLISECONDS, MICROSECONDS, NANOSECONDS -> unit.toMillis(timeout) / 1000d; + default -> unit.toSeconds(timeout); + }; } /** diff --git a/src/main/java/org/springframework/data/redis/repository/query/RedisQueryCreator.java b/src/main/java/org/springframework/data/redis/repository/query/RedisQueryCreator.java index 32199c149e..86e088108c 100644 --- a/src/main/java/org/springframework/data/redis/repository/query/RedisQueryCreator.java +++ b/src/main/java/org/springframework/data/redis/repository/query/RedisQueryCreator.java @@ -52,21 +52,12 @@ protected RedisOperationChain create(Part part, Iterator iterator) { private RedisOperationChain from(Part part, Iterator iterator, RedisOperationChain sink) { switch (part.getType()) { - case SIMPLE_PROPERTY: - sink.sismember(part.getProperty().toDotPath(), iterator.next()); - break; - case TRUE: - sink.sismember(part.getProperty().toDotPath(), true); - break; - case FALSE: - sink.sismember(part.getProperty().toDotPath(), false); - break; - case WITHIN: - case NEAR: - sink.near(getNearPath(part, iterator)); - break; - default: - throw new IllegalArgumentException(String.format("%s is not supported for Redis query derivation", part.getType())); + case SIMPLE_PROPERTY -> sink.sismember(part.getProperty().toDotPath(), iterator.next()); + case TRUE -> sink.sismember(part.getProperty().toDotPath(), true); + case FALSE -> sink.sismember(part.getProperty().toDotPath(), false); + case WITHIN, NEAR -> sink.near(getNearPath(part, iterator)); + default -> throw new IllegalArgumentException( + String.format("%s is not supported for Redis query derivation", part.getType())); } return sink;