diff --git a/pom.xml b/pom.xml index 1739b2090a..cca08ee129 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.springframework.data spring-data-redis - 2.3.0.BUILD-SNAPSHOT + 2.3.0.DATAREDIS-1143-SNAPSHOT Spring Data Redis diff --git a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java index 1b6cb8e469..d9a7da307a 100644 --- a/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java +++ b/src/main/java/org/springframework/data/redis/connection/ClusterCommandExecutor.java @@ -15,11 +15,6 @@ */ package org.springframework.data.redis.connection; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.util.*; import java.util.Map.Entry; import java.util.concurrent.ExecutionException; @@ -657,14 +652,16 @@ public int compare(PositionalKey o1, PositionalKey o2) { * @author Christoph Strobl * @since 2.0.3 */ - @Getter - @EqualsAndHashCode - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) private static class PositionalKey { private final ByteArrayWrapper key; private final int position; + private PositionalKey(ByteArrayWrapper key, int position) { + this.key = key; + this.position = position; + } + static PositionalKey of(byte[] key, int index) { return new PositionalKey(new ByteArrayWrapper(key), index); } @@ -675,6 +672,35 @@ static PositionalKey of(byte[] key, int index) { byte[] getBytes() { return key.getArray(); } + + public ByteArrayWrapper getKey() { + return this.key; + } + + public int getPosition() { + return this.position; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + PositionalKey that = (PositionalKey) o; + + if (position != that.position) + return false; + return ObjectUtils.nullSafeEquals(key, that.key); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(key); + result = 31 * result + position; + return result; + } } /** @@ -684,11 +710,14 @@ byte[] getBytes() { * @author Christoph Strobl * @since 2.0.3 */ - @RequiredArgsConstructor(access = AccessLevel.PRIVATE) private static class PositionalKeys implements Iterable { private final List keys; + private PositionalKeys(List keys) { + this.keys = keys; + } + /** * Create an empty {@link PositionalKeys}. */ diff --git a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java index 0585f602e0..1267eaf5c5 100644 --- a/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java +++ b/src/main/java/org/springframework/data/redis/connection/DefaultStringTuple.java @@ -15,17 +15,15 @@ */ package org.springframework.data.redis.connection; -import lombok.EqualsAndHashCode; - import org.springframework.data.redis.connection.RedisZSetCommands.Tuple; import org.springframework.data.redis.connection.StringRedisConnection.StringTuple; +import org.springframework.util.ObjectUtils; /** * Default implementation for {@link StringTuple} interface. * * @author Costin Leau */ -@EqualsAndHashCode(callSuper = true) public class DefaultStringTuple extends DefaultTuple implements StringTuple { private final String valueAsString; @@ -60,4 +58,25 @@ public String getValueAsString() { public String toString() { return "DefaultStringTuple[value=" + getValueAsString() + ", score=" + getScore() + "]"; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + + DefaultStringTuple that = (DefaultStringTuple) o; + + return ObjectUtils.nullSafeEquals(valueAsString, that.valueAsString); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + ObjectUtils.nullSafeHashCode(valueAsString); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java index f49e7f88e5..2dc6e1cddc 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveRedisConnection.java @@ -15,7 +15,6 @@ */ package org.springframework.data.redis.connection; -import lombok.Data; import reactor.core.publisher.Mono; import java.io.Closeable; @@ -27,6 +26,7 @@ import org.springframework.data.redis.core.ScanOptions; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Redis connection using reactive infrastructure declaring entry points for reactive command execution. @@ -346,12 +346,16 @@ public Range getRange() { * @param command input type. * @param command output type. */ - @Data class CommandResponse { private final I input; private final @Nullable O output; + public CommandResponse(I input, O output) { + this.input = input; + this.output = output; + } + /** * @return {@literal true} if the response is present. An absent {@link CommandResponse} maps to Redis * {@literal (nil)}. @@ -359,6 +363,41 @@ class CommandResponse { public boolean isPresent() { return true; } + + public I getInput() { + return this.input; + } + + @Nullable + public O getOutput() { + return this.output; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + CommandResponse that = (CommandResponse) o; + + if (!ObjectUtils.nullSafeEquals(input, that.input)) { + return false; + } + return ObjectUtils.nullSafeEquals(output, that.output); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(input); + result = 31 * result + ObjectUtils.nullSafeHashCode(output); + return result; + } + + public String toString() { + return "ReactiveRedisConnection.CommandResponse(input=" + this.getInput() + ", output=" + this.getOutput() + ")"; + } } /** diff --git a/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java b/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java index 0f5b420c14..8720c9b8e2 100644 --- a/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java +++ b/src/main/java/org/springframework/data/redis/connection/ReactiveSubscription.java @@ -15,7 +15,6 @@ */ package org.springframework.data.redis.connection; -import lombok.EqualsAndHashCode; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -23,6 +22,7 @@ import java.util.Set; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Subscription for Redis channels using reactive infrastructure. A {@link ReactiveSubscription} allows subscribing to @@ -155,7 +155,6 @@ interface Message { * @author Christoph Strobl * @since 2.1 */ - @EqualsAndHashCode class ChannelMessage implements Message { private final C channel; @@ -194,6 +193,28 @@ public M getMessage() { return message; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ChannelMessage that = (ChannelMessage) o; + + if (!ObjectUtils.nullSafeEquals(channel, that.channel)) { + return false; + } + return ObjectUtils.nullSafeEquals(message, that.message); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(channel); + result = 31 * result + ObjectUtils.nullSafeHashCode(message); + return result; + } + @Override public String toString() { return "ChannelMessage {" + "channel=" + channel + ", message=" + message + '}'; @@ -210,7 +231,6 @@ public String toString() { * @author Christoph Strobl * @since 2.1 */ - @EqualsAndHashCode(callSuper = true) class PatternMessage extends ChannelMessage { private final P pattern; @@ -239,6 +259,27 @@ public P getPattern() { return pattern; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + + PatternMessage that = (PatternMessage) o; + + return ObjectUtils.nullSafeEquals(pattern, that.pattern); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + ObjectUtils.nullSafeHashCode(pattern); + return result; + } + @Override public String toString() { return "PatternMessage{" + "channel=" + getChannel() + ", pattern=" + pattern + ", message=" + getMessage() + '}'; diff --git a/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java index af89a66c7d..72c09281e1 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisGeoCommands.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.connection; -import lombok.Data; -import lombok.RequiredArgsConstructor; - import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -355,12 +352,60 @@ protected GeoRadiusCommandArgs clone() { * @param * @since 1.8 */ - @Data - @RequiredArgsConstructor class GeoLocation { private final T name; private final Point point; + + public GeoLocation(T name, Point point) { + this.name = name; + this.point = point; + } + + public T getName() { + return this.name; + } + + public Point getPoint() { + return this.point; + } + + public boolean equals(final Object o) { + if (o == this) + return true; + if (!(o instanceof GeoLocation)) + return false; + final GeoLocation other = (GeoLocation) o; + if (!other.canEqual((Object) this)) + return false; + final Object this$name = this.getName(); + final Object other$name = other.getName(); + if (this$name == null ? other$name != null : !this$name.equals(other$name)) + return false; + final Object this$point = this.getPoint(); + final Object other$point = other.getPoint(); + if (this$point == null ? other$point != null : !this$point.equals(other$point)) + return false; + return true; + } + + protected boolean canEqual(final Object other) { + return other instanceof GeoLocation; + } + + public int hashCode() { + final int PRIME = 59; + int result = 1; + final Object $name = this.getName(); + result = result * PRIME + ($name == null ? 43 : $name.hashCode()); + final Object $point = this.getPoint(); + result = result * PRIME + ($point == null ? 43 : $point.hashCode()); + return result; + } + + public String toString() { + return "RedisGeoCommands.GeoLocation(name=" + this.getName() + ", point=" + this.getPoint() + ")"; + } } /** diff --git a/src/main/java/org/springframework/data/redis/connection/RedisPassword.java b/src/main/java/org/springframework/data/redis/connection/RedisPassword.java index 6ce6a6e521..50b4ff95dc 100644 --- a/src/main/java/org/springframework/data/redis/connection/RedisPassword.java +++ b/src/main/java/org/springframework/data/redis/connection/RedisPassword.java @@ -15,10 +15,6 @@ */ package org.springframework.data.redis.connection; -import lombok.AccessLevel; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; - import java.util.Arrays; import java.util.NoSuchElementException; import java.util.Optional; @@ -40,14 +36,16 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor(access = AccessLevel.PRIVATE) -@EqualsAndHashCode public class RedisPassword { private static final RedisPassword NONE = new RedisPassword(new char[] {}); private final char[] thePassword; + private RedisPassword(char[] thePassword) { + this.thePassword = thePassword; + } + /** * Create a {@link RedisPassword} from a {@link String}. * @@ -148,4 +146,22 @@ public Optional toOptional() { public String toString() { return String.format("%s[%s]", getClass().getSimpleName(), isPresent() ? "*****" : ""); } + + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + RedisPassword password = (RedisPassword) o; + + return ObjectUtils.nullSafeEquals(thePassword, password.thePassword); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(thePassword); + } } diff --git a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java index c773e8cfc3..568888a2f4 100644 --- a/src/main/java/org/springframework/data/redis/connection/convert/Converters.java +++ b/src/main/java/org/springframework/data/redis/connection/convert/Converters.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.convert; -import lombok.RequiredArgsConstructor; - import java.nio.ByteBuffer; import java.time.Duration; import java.util.ArrayList; @@ -588,12 +586,15 @@ public Distance convert(Double source) { * @param * @since 1.8 */ - @RequiredArgsConstructor static class DeserializingGeoResultsConverter implements Converter>, GeoResults>> { final RedisSerializer serializer; + public DeserializingGeoResultsConverter(RedisSerializer serializer) { + this.serializer = serializer; + } + /* * (non-Javadoc) * @see org.springframework.core.convert.converter.Converter#convert(Object) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java index ac3ce9ce5b..bffe92bb46 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterGeoCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.GeoCoordinate; import redis.clients.jedis.GeoUnit; import redis.clients.jedis.params.GeoRadiusParam; @@ -39,10 +37,15 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterGeoCommands implements RedisGeoCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterGeoCommands(JedisClusterConnection connection) { + + Assert.notNull(connection, "Connection must not be null!"); + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java index 3e2f02263f..b8d834115c 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHashCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import java.util.ArrayList; @@ -40,10 +38,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterHashCommands implements RedisHashCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterHashCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHyperLogLogCommands.java index 7b35efb9b8..6cd4be8a8d 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHyperLogLogCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterHyperLogLogCommands.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.dao.DataAccessException; import org.springframework.dao.InvalidDataAccessApiUsageException; import org.springframework.data.redis.connection.ClusterSlotHashUtil; @@ -30,10 +27,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterHyperLogLogCommands implements RedisHyperLogLogCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterHyperLogLogCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java index f9e7ee9ce2..9b2eb704ec 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterKeyCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.BinaryJedis; import redis.clients.jedis.ScanParams; @@ -57,10 +55,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterKeyCommands implements RedisKeyCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterKeyCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) @@ -495,8 +496,7 @@ public void restore(byte[] key, long ttlInMillis, byte[] serializedValue, boolea } return JedisConverters.toString(this.connection.execute("RESTORE", key, - Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes - ("REPLACE")))); + Arrays.asList(JedisConverters.toBytes(ttlInMillis), serializedValue, JedisConverters.toBytes("REPLACE")))); }, connection.clusterGetNodeForKey(key)); } diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java index 3bfe498ff3..80a8faa7db 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterListCommands.java @@ -19,8 +19,6 @@ import java.util.Collections; import java.util.List; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import org.springframework.dao.DataAccessException; import org.springframework.data.redis.connection.ClusterSlotHashUtil; import org.springframework.data.redis.connection.RedisListCommands; @@ -33,10 +31,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterListCommands implements RedisListCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterListCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java index b5432c31ec..3771e669ea 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterScriptingCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.BinaryJedis; import redis.clients.jedis.JedisCluster; @@ -33,10 +31,13 @@ * @author Pavel Khokhlov * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterScriptingCommands implements RedisScriptingCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterScriptingCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java index f19b36a5ab..ceb86f85fa 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterServerCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.BinaryJedis; import redis.clients.jedis.Jedis; @@ -44,10 +42,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterServerCommands implements RedisClusterServerCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterServerCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java index 82765a3651..2a30289285 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterSetCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import java.util.ArrayList; @@ -43,10 +41,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterSetCommands implements RedisSetCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterSetCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java index c438de4457..cc39ec59f0 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterStringCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.BinaryJedis; import redis.clients.jedis.Connection; import redis.clients.jedis.params.SetParams; @@ -45,10 +43,13 @@ * @author Xiaohu Zhang * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterStringCommands implements RedisStringCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterStringCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) @@ -131,7 +132,8 @@ public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption op Assert.notNull(expiration, "Expiration must not be null!"); Assert.notNull(option, "Option must not be null!"); - SetParams setParams = JedisConverters.toSetCommandExPxArgument(expiration, JedisConverters.toSetCommandNxXxArgument(option)); + SetParams setParams = JedisConverters.toSetCommandExPxArgument(expiration, + JedisConverters.toSetCommandNxXxArgument(option)); try { return Converters.stringToBoolean(connection.getCluster().set(key, value, setParams)); diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java index 6d6db603cc..33c33418d7 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisClusterZSetCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import redis.clients.jedis.ZParams; @@ -39,10 +37,13 @@ * @author Clement Ong * @since 2.0 */ -@RequiredArgsConstructor class JedisClusterZSetCommands implements RedisZSetCommands { - private final @NonNull JedisClusterConnection connection; + private final JedisClusterConnection connection; + + JedisClusterZSetCommands(JedisClusterConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java index 28b1cb5b6d..4656e920cb 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisGeoCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.GeoCoordinate; import redis.clients.jedis.GeoUnit; @@ -39,10 +37,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisGeoCommands implements RedisGeoCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisGeoCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java index ff8fd8b804..e958aa3c1f 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHashCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanResult; @@ -38,10 +36,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisHashCommands implements RedisHashCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisHashCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHyperLogLogCommands.java index b5d2419bc9..bdefb53248 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisHyperLogLogCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisHyperLogLogCommands.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import org.springframework.data.redis.connection.RedisHyperLogLogCommands; import org.springframework.util.Assert; @@ -26,10 +23,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisHyperLogLogCommands implements RedisHyperLogLogCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisHyperLogLogCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisKeyCommands.java index 76e7e5a896..a423ab7ce6 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisKeyCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import redis.clients.jedis.SortingParams; @@ -43,10 +41,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisKeyCommands implements RedisKeyCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisKeyCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisListCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisListCommands.java index 1de9380c02..4346f0e1f4 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisListCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.Protocol; import java.util.ArrayList; @@ -30,10 +28,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisListCommands implements RedisListCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisListCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisScriptingCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisScriptingCommands.java index 9633d17f99..0fbca4b2a0 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisScriptingCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisScriptingCommands.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.List; import org.springframework.data.redis.connection.RedisScriptingCommands; @@ -28,10 +25,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisScriptingCommands implements RedisScriptingCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisScriptingCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisServerCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisServerCommands.java index 93fbffb605..910badf591 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisServerCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisServerCommands.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; - import java.util.List; import java.util.Properties; @@ -33,12 +30,15 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisServerCommands implements RedisServerCommands { private static final String SHUTDOWN_SCRIPT = "return redis.call('SHUTDOWN','%s')"; - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisServerCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisSetCommands.java index 2885e1bd0d..def89d9f18 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisSetCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import java.util.ArrayList; @@ -35,10 +33,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisSetCommands implements RedisSetCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisSetCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisStringCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisStringCommands.java index afaa361f4d..2b47ada137 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisStringCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisStringCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.BitPosParams; import redis.clients.jedis.Client; import redis.clients.jedis.params.SetParams; @@ -38,10 +36,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisStringCommands implements RedisStringCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + JedisStringCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) @@ -157,7 +158,8 @@ public Boolean set(byte[] key, byte[] value, Expiration expiration, SetOption op Assert.notNull(expiration, "Expiration must not be null!"); Assert.notNull(option, "Option must not be null!"); - SetParams params = JedisConverters.toSetCommandExPxArgument(expiration, JedisConverters.toSetCommandNxXxArgument(option)); + SetParams params = JedisConverters.toSetCommandExPxArgument(expiration, + JedisConverters.toSetCommandNxXxArgument(option)); try { if (isPipelined()) { diff --git a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java index e7443da550..793be788d6 100644 --- a/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/jedis/JedisZSetCommands.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.jedis; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import redis.clients.jedis.ScanParams; import redis.clients.jedis.ScanResult; import redis.clients.jedis.ZParams; @@ -38,10 +36,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class JedisZSetCommands implements RedisZSetCommands { - private final @NonNull JedisConnection connection; + private final JedisConnection connection; + + public JedisZSetCommands(JedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) 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 70b69b3973..afd4143af8 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 @@ -22,7 +22,6 @@ import io.lettuce.core.cluster.SlotHash; import io.lettuce.core.cluster.api.StatefulRedisClusterConnection; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.RequiredArgsConstructor; import java.time.Duration; import java.util.ArrayList; @@ -34,7 +33,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.beans.factory.DisposableBean; import org.springframework.dao.DataAccessException; import org.springframework.dao.DataAccessResourceFailureException; @@ -666,12 +664,15 @@ protected interface LettuceMultiKeyClusterCommandCallback * @author Christoph Strobl * @since 1.7 */ - @RequiredArgsConstructor static class LettuceClusterNodeResourceProvider implements ClusterNodeResourceProvider, DisposableBean { private final LettuceConnectionProvider connectionProvider; private volatile @Nullable StatefulRedisClusterConnection connection; + LettuceClusterNodeResourceProvider(LettuceConnectionProvider connectionProvider) { + this.connectionProvider = connectionProvider; + } + @Override @SuppressWarnings("unchecked") public RedisClusterCommands getResourceForSpecificNode(RedisClusterNode node) { diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java index d9959c547a..18bbe4bc45 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnection.java @@ -39,7 +39,6 @@ import io.lettuce.core.protocol.CommandType; import io.lettuce.core.pubsub.StatefulRedisPubSubConnection; import io.lettuce.core.sentinel.api.StatefulRedisSentinelConnection; -import lombok.RequiredArgsConstructor; import java.lang.reflect.Constructor; import java.util.ArrayList; @@ -1308,11 +1307,14 @@ public CommandOutput getTypeHint(CommandType type, CommandOutput defaultType) { } } - @RequiredArgsConstructor static class LettucePoolConnectionProvider implements LettuceConnectionProvider { private final LettucePool pool; + LettucePoolConnectionProvider(LettucePool pool) { + this.pool = pool; + } + /* * (non-Javadoc) * @see org.springframework.data.redis.connection.lettuce.LettuceConnectionProvider#getConnection(java.lang.Class) @@ -1437,8 +1439,9 @@ public interface PipeliningFlushState { /** * Implementation to flush on each command. - * @author Mark Paluch - * @since 2.3 + * + * @author Mark Paluch + * @since 2.3 */ private enum FlushEachCommand implements PipeliningFlushPolicy, PipeliningFlushState { @@ -1461,8 +1464,9 @@ public void onClose(StatefulConnection connection) {} /** * Implementation to flush on closing the pipeline. - * @author Mark Paluch - * @since 2.3 + * + * @author Mark Paluch + * @since 2.3 */ private enum FlushOnClose implements PipeliningFlushPolicy, PipeliningFlushState { @@ -1492,8 +1496,9 @@ public void onClose(StatefulConnection connection) { /** * Pipeline state for buffered flushing. - * @author Mark Paluch - * @since 2.3 + * + * @author Mark Paluch + * @since 2.3 */ private static class BufferedFlushing implements PipeliningFlushState { diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java index e39df82a87..c2195effa8 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceConnectionFactory.java @@ -30,7 +30,6 @@ import io.lettuce.core.cluster.api.StatefulRedisClusterConnection; import io.lettuce.core.codec.RedisCodec; import io.lettuce.core.resource.ClientResources; -import lombok.RequiredArgsConstructor; import java.nio.ByteBuffer; import java.time.Duration; @@ -1176,7 +1175,6 @@ private long getClientTimeout() { * @author Christoph Strobl * @since 2.1 */ - @RequiredArgsConstructor class SharedConnection { private final LettuceConnectionProvider connectionProvider; @@ -1186,6 +1184,10 @@ class SharedConnection { private @Nullable StatefulConnection connection; + SharedConnection(LettuceConnectionProvider connectionProvider) { + this.connectionProvider = connectionProvider; + } + /** * Returns a valid Lettuce connection. Initializes and validates the connection if * {@link #setValidateConnection(boolean) enabled}. diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceGeoCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceGeoCommands.java index 6431103ff6..eb5b8f373f 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceGeoCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceGeoCommands.java @@ -20,8 +20,6 @@ import io.lettuce.core.GeoWithin; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.ArrayList; import java.util.Collection; @@ -48,10 +46,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceGeoCommands implements RedisGeoCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceGeoCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHashCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHashCommands.java index bbc0b42536..b930bd944d 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHashCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHashCommands.java @@ -19,8 +19,6 @@ import io.lettuce.core.ScanArgs; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.List; import java.util.Map; @@ -41,10 +39,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceHashCommands implements RedisHashCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceHashCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHyperLogLogCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHyperLogLogCommands.java index 57df4a0784..a2ea035d3b 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHyperLogLogCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceHyperLogLogCommands.java @@ -18,8 +18,6 @@ import io.lettuce.core.api.sync.RedisHLLCommands; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import org.springframework.dao.DataAccessException; import org.springframework.data.redis.connection.RedisHyperLogLogCommands; @@ -30,10 +28,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceHyperLogLogCommands implements RedisHyperLogLogCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceHyperLogLogCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceKeyCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceKeyCommands.java index 3d6db793ff..d81366d75f 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceKeyCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceKeyCommands.java @@ -22,8 +22,6 @@ import io.lettuce.core.SortArgs; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.time.Duration; import java.util.List; @@ -47,10 +45,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceKeyCommands implements RedisKeyCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceKeyCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceListCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceListCommands.java index 7d72d42b9f..7c33c27986 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceListCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceListCommands.java @@ -17,8 +17,6 @@ import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.List; @@ -31,10 +29,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceListCommands implements RedisListCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceListCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactivePubSubCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactivePubSubCommands.java index badc43823a..1eedab882a 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactivePubSubCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactivePubSubCommands.java @@ -16,8 +16,6 @@ package org.springframework.data.redis.connection.lettuce; import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -35,10 +33,13 @@ * @author Christoph Strobl * @since 2.1 */ -@RequiredArgsConstructor class LettuceReactivePubSubCommands implements ReactivePubSubCommands { - private final @NonNull LettuceReactiveRedisConnection connection; + private final LettuceReactiveRedisConnection connection; + + LettuceReactivePubSubCommands(LettuceReactiveRedisConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSubscription.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSubscription.java index 6a516a0b20..40d1e736df 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSubscription.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceReactiveSubscription.java @@ -16,7 +16,6 @@ package org.springframework.data.redis.connection.lettuce; import io.lettuce.core.pubsub.api.reactive.RedisPubSubReactiveCommands; -import lombok.RequiredArgsConstructor; import reactor.core.Disposable; import reactor.core.publisher.ConnectableFlux; import reactor.core.publisher.Flux; @@ -186,7 +185,6 @@ public Mono cancel() { * * @author Mark Paluch */ - @RequiredArgsConstructor static class State { private final Set targets = new ConcurrentSkipListSet<>(); @@ -196,6 +194,10 @@ static class State { private volatile @Nullable Disposable disposable; + State(Function exceptionTranslator) { + this.exceptionTranslator = exceptionTranslator; + } + /** * Subscribe to {@code targets} using subscribe {@link Function} and register {@code targets} after subscription. * diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceServerCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceServerCommands.java index ae12e18a97..2de1a4bd15 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceServerCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceServerCommands.java @@ -17,8 +17,6 @@ import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.List; import java.util.Properties; @@ -35,10 +33,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceServerCommands implements RedisServerCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceServerCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceSetCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceSetCommands.java index 903a7902cd..dd1ef72590 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceSetCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceSetCommands.java @@ -19,8 +19,6 @@ import io.lettuce.core.ValueScanCursor; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.ArrayList; import java.util.List; @@ -40,10 +38,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceSetCommands implements RedisSetCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceSetCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java index 90f015ee2e..3290712ffc 100644 --- a/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java +++ b/src/main/java/org/springframework/data/redis/connection/lettuce/LettuceStreamCommands.java @@ -21,8 +21,6 @@ import io.lettuce.core.XReadArgs; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.Arrays; import java.util.List; @@ -51,10 +49,13 @@ * @author Tugdual Grall * @since 2.2 */ -@RequiredArgsConstructor class LettuceStreamCommands implements RedisStreamCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceStreamCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) 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 58e71ce2e5..0de36a677d 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 @@ -19,8 +19,6 @@ import io.lettuce.core.RedisFuture; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.List; import java.util.Map; @@ -40,10 +38,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceStringCommands implements RedisStringCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceStringCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) @@ -727,8 +728,7 @@ public Long bitPos(byte[] key, boolean bit, Range range) { if (isPipelined()) { pipeline(this.connection.newLettuceResult(futureResult)); - } - else if (isQueueing()) { + } else if (isQueueing()) { transaction(this.connection.newLettuceResult(futureResult)); } return null; 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 ab9cc38529..69f027c6e9 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 @@ -21,8 +21,6 @@ import io.lettuce.core.ZStoreArgs; import io.lettuce.core.cluster.api.async.RedisClusterAsyncCommands; import io.lettuce.core.cluster.api.sync.RedisClusterCommands; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import java.util.List; import java.util.Set; @@ -41,10 +39,13 @@ * @author Mark Paluch * @since 2.0 */ -@RequiredArgsConstructor class LettuceZSetCommands implements RedisZSetCommands { - private final @NonNull LettuceConnection connection; + private final LettuceConnection connection; + + LettuceZSetCommands(LettuceConnection connection) { + this.connection = connection; + } /* * (non-Javadoc) @@ -843,12 +844,11 @@ public Set zRangeByLex(byte[] key, Range range, Limit limit) { if (limit.isUnlimited()) { pipeline( connection.newLettuceResult(getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true)), - LettuceConverters.bytesListToBytesSet())); + LettuceConverters.bytesListToBytesSet())); } else { - pipeline(connection.newLettuceResult( - getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true), - LettuceConverters.toLimit(limit)), - LettuceConverters.bytesListToBytesSet())); + pipeline( + connection.newLettuceResult(getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true), + LettuceConverters.toLimit(limit)), LettuceConverters.bytesListToBytesSet())); } return null; } @@ -858,10 +858,9 @@ public Set zRangeByLex(byte[] key, Range range, Limit limit) { connection.newLettuceResult(getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true)), LettuceConverters.bytesListToBytesSet())); } else { - transaction(connection.newLettuceResult( - getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true), - LettuceConverters.toLimit(limit)), - LettuceConverters.bytesListToBytesSet())); + transaction( + connection.newLettuceResult(getAsyncConnection().zrangebylex(key, LettuceConverters.toRange(range, true), + LettuceConverters.toLimit(limit)), LettuceConverters.bytesListToBytesSet())); } return null; } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/Consumer.java b/src/main/java/org/springframework/data/redis/connection/stream/Consumer.java index e4066b80b4..eafc4e79bf 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/Consumer.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/Consumer.java @@ -15,10 +15,8 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; -import lombok.Getter; - import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Value object representing a Stream consumer within a consumer group. Group name and consumer name are encoded as @@ -27,8 +25,6 @@ * @author Mark Paluch * @see 2.2 */ -@EqualsAndHashCode -@Getter public class Consumer { private final String group; @@ -58,4 +54,34 @@ public static Consumer from(String group, String name) { public String toString() { return String.format("%s:%s", group, name); } + + public String getGroup() { + return this.group; + } + + public String getName() { + return this.name; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + Consumer consumer = (Consumer) o; + + if (!ObjectUtils.nullSafeEquals(group, consumer.group)) { + return false; + } + return ObjectUtils.nullSafeEquals(name, consumer.name); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(group); + result = 31 * result + ObjectUtils.nullSafeHashCode(name); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/ReadOffset.java b/src/main/java/org/springframework/data/redis/connection/stream/ReadOffset.java index 1023b5164b..236fb2528a 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/ReadOffset.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/ReadOffset.java @@ -15,18 +15,12 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Value object representing read offset for a Stream. */ -@EqualsAndHashCode -@ToString -@Getter public final class ReadOffset { private final String offset; @@ -81,4 +75,30 @@ public static ReadOffset from(RecordId offset) { return from(offset.getValue()); } + + public String getOffset() { + return this.offset; + } + + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ReadOffset that = (ReadOffset) o; + + return ObjectUtils.nullSafeEquals(offset, that.offset); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(offset); + } + + public String toString() { + return "ReadOffset(offset=" + this.getOffset() + ")"; + } } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/RecordId.java b/src/main/java/org/springframework/data/redis/connection/stream/RecordId.java index 9dbea1158e..eec964685c 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/RecordId.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/RecordId.java @@ -15,11 +15,10 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; - import org.springframework.lang.Nullable; import org.springframework.util.Assert; import org.springframework.util.NumberUtils; +import org.springframework.util.ObjectUtils; import org.springframework.util.StringUtils; /** @@ -30,7 +29,6 @@ * @since 2.2 * @see Redis Documentation - Entriy ID */ -@EqualsAndHashCode public class RecordId { private static final String GENERATE_ID = "*"; @@ -154,4 +152,21 @@ public String toString() { private Long value(int index) { return NumberUtils.parseNumber(StringUtils.split(raw, DELIMITER)[index], Long.class); } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + RecordId recordId = (RecordId) o; + + return ObjectUtils.nullSafeEquals(raw, recordId.raw); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(raw); + } } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/StreamOffset.java b/src/main/java/org/springframework/data/redis/connection/stream/StreamOffset.java index 7953ba326a..41996f6bbc 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/StreamOffset.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/StreamOffset.java @@ -15,11 +15,8 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Value object representing a Stream Id with its offset. @@ -27,9 +24,6 @@ * @author Mark Paluch * @see 2.2 */ -@EqualsAndHashCode -@ToString -@Getter public final class StreamOffset { private final K key; @@ -92,4 +86,40 @@ public static StreamOffset from(Record reference) { return create(reference.getStream(), ReadOffset.from(reference.getId())); } + + public K getKey() { + return this.key; + } + + public ReadOffset getOffset() { + return this.offset; + } + + @Override + public String toString() { + return "StreamOffset{" + "key=" + key + ", offset=" + offset + '}'; + } + + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + StreamOffset that = (StreamOffset) o; + + if (!ObjectUtils.nullSafeEquals(key, that.key)) { + return false; + } + return ObjectUtils.nullSafeEquals(offset, that.offset); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(key); + result = 31 * result + ObjectUtils.nullSafeHashCode(offset); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/StreamReadOptions.java b/src/main/java/org/springframework/data/redis/connection/stream/StreamReadOptions.java index f12c5157c9..5a15c98e73 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/StreamReadOptions.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/StreamReadOptions.java @@ -15,14 +15,11 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; -import lombok.Getter; -import lombok.ToString; - import java.time.Duration; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Options for reading messages from a Redis Stream. @@ -31,9 +28,6 @@ * @author Christoph Strobl * @see 2.2 */ -@EqualsAndHashCode -@ToString -@Getter public class StreamReadOptions { private static final StreamReadOptions EMPTY = new StreamReadOptions(null, null, false); @@ -113,4 +107,49 @@ public StreamReadOptions count(long count) { public boolean isBlocking() { return getBlock() != null && getBlock() >= 0; } + + @Nullable + public Long getBlock() { + return block; + } + + @Nullable + public Long getCount() { + return count; + } + + public boolean isNoack() { + return noack; + } + + @Override + public String toString() { + return "StreamReadOptions{" + "block=" + block + ", count=" + count + ", noack=" + noack + ", autoAcknowledge=" + + autoAcknowledge() + ", blocking=" + isBlocking() + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + StreamReadOptions that = (StreamReadOptions) o; + + if (noack != that.noack) + return false; + if (!ObjectUtils.nullSafeEquals(block, that.block)) { + return false; + } + return ObjectUtils.nullSafeEquals(count, that.count); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(block); + result = 31 * result + ObjectUtils.nullSafeHashCode(count); + result = 31 * result + (noack ? 1 : 0); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/connection/stream/StreamRecords.java b/src/main/java/org/springframework/data/redis/connection/stream/StreamRecords.java index bfc8068430..bb892bd879 100644 --- a/src/main/java/org/springframework/data/redis/connection/stream/StreamRecords.java +++ b/src/main/java/org/springframework/data/redis/connection/stream/StreamRecords.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.connection.stream; -import lombok.EqualsAndHashCode; - import java.nio.ByteBuffer; import java.util.Iterator; import java.util.Map; @@ -386,7 +384,6 @@ public StringMapBackedRecord withId(RecordId id) { * @param * @param */ - @EqualsAndHashCode static class ObjectBackedRecord implements ObjectRecord { private @Nullable S stream; @@ -431,5 +428,31 @@ public ObjectRecord withStreamKey(SK key) { public String toString() { return "ObjectBackedRecord{" + "recordId=" + recordId + ", value=" + value + '}'; } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ObjectBackedRecord that = (ObjectBackedRecord) o; + + if (!ObjectUtils.nullSafeEquals(stream, that.stream)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(recordId, that.recordId)) { + return false; + } + return ObjectUtils.nullSafeEquals(value, that.value); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(stream); + result = 31 * result + ObjectUtils.nullSafeHashCode(recordId); + result = 31 * result + ObjectUtils.nullSafeHashCode(value); + return result; + } } } diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveGeoOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveGeoOperations.java index 61cbe76b9d..dd8d8e4419 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveGeoOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveGeoOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -46,11 +44,17 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveGeoOperations implements ReactiveGeoOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveGeoOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java index 89983db09a..e6564f5c17 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveHashOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -40,11 +38,17 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveHashOperations implements ReactiveHashOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveHashOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperations.java index 4dab560b6b..87d5361703 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveHyperLogLogOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -35,11 +33,17 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveHyperLogLogOperations implements ReactiveHyperLogLogOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveHyperLogLogOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* (non-Javadoc) * @see org.springframework.data.redis.core.ReactiveHyperLogLogOperations#add(java.lang.Object, java.lang.Object[]) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveListOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveListOperations.java index c9220e9c3c..7aa2019b70 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveListOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveListOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -41,11 +39,17 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveListOperations implements ReactiveListOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveListOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* (non-Javadoc) * @see org.springframework.data.redis.core.ReactiveListOperations#range(java.lang.Object, long, long) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveSetOperations.java index 575d71f9c4..70a09f4c18 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveSetOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -40,11 +38,17 @@ * @author Roman Bezpalko * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveSetOperations implements ReactiveSetOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveSetOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* * (non-Javadoc) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveValueOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveValueOperations.java index f15aa57d9b..bdbbfc4846 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveValueOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveValueOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -45,11 +43,17 @@ * @author Jiahe Cai * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveValueOperations implements ReactiveValueOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + DefaultReactiveValueOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* (non-Javadoc) * @see org.springframework.data.redis.core.ReactiveValueOperations#set(java.lang.Object, java.lang.Object) diff --git a/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java b/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java index 1be9cd0a8d..f5f42d5403 100644 --- a/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java +++ b/src/main/java/org/springframework/data/redis/core/DefaultReactiveZSetOperations.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.NonNull; -import lombok.RequiredArgsConstructor; import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; @@ -47,11 +45,17 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultReactiveZSetOperations implements ReactiveZSetOperations { - private final @NonNull ReactiveRedisTemplate template; - private final @NonNull RedisSerializationContext serializationContext; + private final ReactiveRedisTemplate template; + private final RedisSerializationContext serializationContext; + + public DefaultReactiveZSetOperations(ReactiveRedisTemplate template, + RedisSerializationContext serializationContext) { + + this.template = template; + this.serializationContext = serializationContext; + } /* * (non-Javadoc) 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 43c913f6d5..e532810b4e 100644 --- a/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java +++ b/src/main/java/org/springframework/data/redis/core/RedisConnectionUtils.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -24,7 +22,6 @@ import org.aopalliance.intercept.MethodInvocation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; - import org.springframework.aop.framework.ProxyFactory; import org.springframework.cglib.proxy.MethodProxy; import org.springframework.dao.DataAccessException; @@ -306,13 +303,20 @@ private static void doCloseConnection(RedisConnection connection) { * @author Christoph Strobl * @author Thomas Darimont */ - @RequiredArgsConstructor private static class RedisTransactionSynchronizer extends TransactionSynchronizationAdapter { private final RedisConnectionHolder connHolder; private final RedisConnection connection; private final RedisConnectionFactory factory; + RedisTransactionSynchronizer(RedisConnectionHolder connHolder, RedisConnection connection, + RedisConnectionFactory factory) { + + this.connHolder = connHolder; + this.connection = connection; + this.factory = factory; + } + @Override public void afterCompletion(int status) { diff --git a/src/main/java/org/springframework/data/redis/core/convert/Bucket.java b/src/main/java/org/springframework/data/redis/core/convert/Bucket.java index a6822c518b..0a27297f87 100644 --- a/src/main/java/org/springframework/data/redis/core/convert/Bucket.java +++ b/src/main/java/org/springframework/data/redis/core/convert/Bucket.java @@ -15,11 +15,6 @@ */ package org.springframework.data.redis.core.convert; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.NonNull; - import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; import java.util.Collection; @@ -302,13 +297,19 @@ private String toUtf8String(byte[] raw) { * @author Mark Paluch * @since 2.1 */ - @AllArgsConstructor(access = AccessLevel.PRIVATE) - @Getter public static class BucketPropertyPath { - private final @NonNull Bucket bucket; + private final Bucket bucket; private final @Nullable String prefix; + private BucketPropertyPath(Bucket bucket, String prefix) { + + Assert.notNull(bucket, "Bucket must not be null!"); + + this.bucket = bucket; + this.prefix = prefix; + } + /** * Creates a top-level {@link BucketPropertyPath} given {@link Bucket}. * @@ -355,5 +356,14 @@ public void put(String key, byte[] value) { private String getPath(String key) { return StringUtils.hasText(prefix) ? prefix + "." + key : key; } + + public Bucket getBucket() { + return this.bucket; + } + + @Nullable + public String getPrefix() { + return this.prefix; + } } } diff --git a/src/main/java/org/springframework/data/redis/core/convert/GeoIndexedPropertyValue.java b/src/main/java/org/springframework/data/redis/core/convert/GeoIndexedPropertyValue.java index 496f6be64c..33b012d8cf 100644 --- a/src/main/java/org/springframework/data/redis/core/convert/GeoIndexedPropertyValue.java +++ b/src/main/java/org/springframework/data/redis/core/convert/GeoIndexedPropertyValue.java @@ -17,21 +17,25 @@ import org.springframework.data.geo.Point; -import lombok.Data; - /** * {@link IndexedData} implementation indicating storage of data within a Redis GEO structure. * * @author Christoph Strobl * @since 1.8 */ -@Data public class GeoIndexedPropertyValue implements IndexedData { private final String keyspace; private final String indexName; private final Point value; + public GeoIndexedPropertyValue(String keyspace, String indexName, Point value) { + + this.keyspace = keyspace; + this.indexName = indexName; + this.value = value; + } + /* * (non-Javadoc) * @see org.springframework.data.redis.core.convert.IndexedData#getIndexName() @@ -64,4 +68,52 @@ public static String geoIndexName(String path) { sb.setCharAt(index, ':'); return sb.toString(); } + + public Point getValue() { + return this.value; + } + + public boolean equals(final Object o) { + if (o == this) + return true; + if (!(o instanceof GeoIndexedPropertyValue)) + return false; + final GeoIndexedPropertyValue other = (GeoIndexedPropertyValue) o; + if (!other.canEqual((Object) this)) + return false; + final Object this$keyspace = this.getKeyspace(); + final Object other$keyspace = other.getKeyspace(); + if (this$keyspace == null ? other$keyspace != null : !this$keyspace.equals(other$keyspace)) + return false; + final Object this$indexName = this.getIndexName(); + final Object other$indexName = other.getIndexName(); + if (this$indexName == null ? other$indexName != null : !this$indexName.equals(other$indexName)) + return false; + final Object this$value = this.getValue(); + final Object other$value = other.getValue(); + if (this$value == null ? other$value != null : !this$value.equals(other$value)) + return false; + return true; + } + + protected boolean canEqual(final Object other) { + return other instanceof GeoIndexedPropertyValue; + } + + public int hashCode() { + final int PRIME = 59; + int result = 1; + final Object $keyspace = this.getKeyspace(); + result = result * PRIME + ($keyspace == null ? 43 : $keyspace.hashCode()); + final Object $indexName = this.getIndexName(); + result = result * PRIME + ($indexName == null ? 43 : $indexName.hashCode()); + final Object $value = this.getValue(); + result = result * PRIME + ($value == null ? 43 : $value.hashCode()); + return result; + } + + public String toString() { + return "GeoIndexedPropertyValue(keyspace=" + this.getKeyspace() + ", indexName=" + this.getIndexName() + ", value=" + + this.getValue() + ")"; + } } diff --git a/src/main/java/org/springframework/data/redis/core/convert/IndexedDataFactoryProvider.java b/src/main/java/org/springframework/data/redis/core/convert/IndexedDataFactoryProvider.java index 2ae03269d9..b1f83f733a 100644 --- a/src/main/java/org/springframework/data/redis/core/convert/IndexedDataFactoryProvider.java +++ b/src/main/java/org/springframework/data/redis/core/convert/IndexedDataFactoryProvider.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.core.convert; -import lombok.RequiredArgsConstructor; - import org.springframework.data.geo.Point; import org.springframework.data.redis.core.index.GeoIndexDefinition; import org.springframework.data.redis.core.index.IndexDefinition; @@ -52,11 +50,14 @@ static interface IndexedDataFactory { * @author Christoph Strobl * @since 1.8 */ - @RequiredArgsConstructor static class SimpleIndexedPropertyValueFactory implements IndexedDataFactory { final SimpleIndexDefinition indexDefinition; + SimpleIndexedPropertyValueFactory(SimpleIndexDefinition indexDefinition) { + this.indexDefinition = indexDefinition; + } + public SimpleIndexedPropertyValue createIndexedDataFor(Object value) { return new SimpleIndexedPropertyValue(indexDefinition.getKeyspace(), indexDefinition.getIndexName(), @@ -68,11 +69,14 @@ public SimpleIndexedPropertyValue createIndexedDataFor(Object value) { * @author Christoph Strobl * @since 1.8 */ - @RequiredArgsConstructor static class GeoIndexedPropertyValueFactory implements IndexedDataFactory { final GeoIndexDefinition indexDefinition; + public GeoIndexedPropertyValueFactory(GeoIndexDefinition indexDefinition) { + this.indexDefinition = indexDefinition; + } + public GeoIndexedPropertyValue createIndexedDataFor(Object value) { return new GeoIndexedPropertyValue(indexDefinition.getKeyspace(), indexDefinition.getPath(), diff --git a/src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java b/src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java index af8f7be3aa..30378c9c2b 100644 --- a/src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java +++ b/src/main/java/org/springframework/data/redis/core/convert/MappingRedisConverter.java @@ -15,14 +15,18 @@ */ package org.springframework.data.redis.core.convert; -import lombok.AccessLevel; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.lang.reflect.Array; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -1031,13 +1035,19 @@ private void initializeConverters() { * @author Christoph Strobl * @author Mark Paluch */ - @RequiredArgsConstructor private class ConverterAwareParameterValueProvider implements PropertyValueProvider { private final String path; private final RedisData source; private final ConversionService conversionService; + ConverterAwareParameterValueProvider(String path, RedisData source, ConversionService conversionService) { + + this.path = path; + this.source = source; + this.conversionService = conversionService; + } + @Override @SuppressWarnings("unchecked") public T getPropertyValue(RedisPersistentProperty property) { @@ -1145,8 +1155,6 @@ public int compareTo(Part that) { * @author Mark Paluch * @since 1.8.10 */ - @AllArgsConstructor(access = AccessLevel.PRIVATE) - @Getter public static class KeyspaceIdentifier { public static final String PHANTOM = "phantom"; @@ -1157,6 +1165,13 @@ public static class KeyspaceIdentifier { private String id; private boolean phantomKey; + private KeyspaceIdentifier(String keyspace, String id, boolean phantomKey) { + + this.keyspace = keyspace; + this.id = id; + this.phantomKey = phantomKey; + } + /** * Parse a {@code key} into {@link KeyspaceIdentifier}. * @@ -1198,6 +1213,18 @@ public static boolean isValid(String key) { return keyspaceEndIndex > 0 && key.length() > keyspaceEndIndex; } + + public String getKeyspace() { + return this.keyspace; + } + + public String getId() { + return this.id; + } + + public boolean isPhantomKey() { + return this.phantomKey; + } } /** @@ -1207,8 +1234,6 @@ public static boolean isValid(String key) { * @author Mark Paluch * @since 1.8.10 */ - @AllArgsConstructor(access = AccessLevel.PRIVATE) - @Getter public static class BinaryKeyspaceIdentifier { public static final byte[] PHANTOM = KeyspaceIdentifier.PHANTOM.getBytes(); @@ -1219,6 +1244,13 @@ public static class BinaryKeyspaceIdentifier { private byte[] id; private boolean phantomKey; + private BinaryKeyspaceIdentifier(byte[] keyspace, byte[] id, boolean phantomKey) { + + this.keyspace = keyspace; + this.id = id; + this.phantomKey = phantomKey; + } + /** * Parse a binary {@code key} into {@link BinaryKeyspaceIdentifier}. * @@ -1280,5 +1312,17 @@ private static byte[] extractKeyspace(byte[] key, int keyspaceEndIndex) { return keyspace; } + + public byte[] getKeyspace() { + return this.keyspace; + } + + public byte[] getId() { + return this.id; + } + + public boolean isPhantomKey() { + return this.phantomKey; + } } } diff --git a/src/main/java/org/springframework/data/redis/core/convert/SimpleIndexedPropertyValue.java b/src/main/java/org/springframework/data/redis/core/convert/SimpleIndexedPropertyValue.java index 60fccf7d7b..43700199c8 100644 --- a/src/main/java/org/springframework/data/redis/core/convert/SimpleIndexedPropertyValue.java +++ b/src/main/java/org/springframework/data/redis/core/convert/SimpleIndexedPropertyValue.java @@ -15,8 +15,7 @@ */ package org.springframework.data.redis.core.convert; -import lombok.EqualsAndHashCode; -import lombok.ToString; +import org.springframework.util.ObjectUtils; /** * {@link IndexedData} implementation indicating storage of data within a Redis Set. @@ -25,8 +24,6 @@ * @author Rob Winch * @since 1.7 */ -@EqualsAndHashCode -@ToString public class SimpleIndexedPropertyValue implements IndexedData { private final String keyspace; @@ -73,4 +70,36 @@ public String getIndexName() { public String getKeyspace() { return this.keyspace; } + + @Override + public String toString() { + return "SimpleIndexedPropertyValue{" + "keyspace='" + keyspace + '\'' + ", indexName='" + indexName + '\'' + + ", value=" + value + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + SimpleIndexedPropertyValue that = (SimpleIndexedPropertyValue) o; + + if (!ObjectUtils.nullSafeEquals(keyspace, that.keyspace)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(indexName, that.indexName)) { + return false; + } + return ObjectUtils.nullSafeEquals(value, that.value); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(keyspace); + result = 31 * result + ObjectUtils.nullSafeHashCode(indexName); + result = 31 * result + ObjectUtils.nullSafeHashCode(value); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/core/index/IndexDefinition.java b/src/main/java/org/springframework/data/redis/core/index/IndexDefinition.java index 5e61c03708..ce369caabd 100644 --- a/src/main/java/org/springframework/data/redis/core/index/IndexDefinition.java +++ b/src/main/java/org/springframework/data/redis/core/index/IndexDefinition.java @@ -15,11 +15,10 @@ */ package org.springframework.data.redis.core.index; -import lombok.Value; - import java.util.Collection; import org.springframework.data.util.TypeInformation; +import org.springframework.util.ObjectUtils; /** * {@link IndexDefinition} allow to set up a blueprint for creating secondary index structures in Redis. Setting up @@ -68,11 +67,60 @@ interface Condition { * @author Christoph Strobl * @since 1.7 */ - @Value - public class IndexingContext { + final class IndexingContext { private final String keyspace; private final String path; private final TypeInformation typeInformation; + + public IndexingContext(String keyspace, String path, TypeInformation typeInformation) { + + this.keyspace = keyspace; + this.path = path; + this.typeInformation = typeInformation; + } + + public String getKeyspace() { + return this.keyspace; + } + + public String getPath() { + return this.path; + } + + public TypeInformation getTypeInformation() { + return this.typeInformation; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + IndexingContext that = (IndexingContext) o; + + if (!ObjectUtils.nullSafeEquals(keyspace, that.keyspace)) { + return false; + } + if (!ObjectUtils.nullSafeEquals(path, that.path)) { + return false; + } + return ObjectUtils.nullSafeEquals(typeInformation, that.typeInformation); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(keyspace); + result = 31 * result + ObjectUtils.nullSafeHashCode(path); + result = 31 * result + ObjectUtils.nullSafeHashCode(typeInformation); + return result; + } + + public String toString() { + return "IndexDefinition.IndexingContext(keyspace=" + this.getKeyspace() + ", path=" + this.getPath() + + ", typeInformation=" + this.getTypeInformation() + ")"; + } } } diff --git a/src/main/java/org/springframework/data/redis/core/index/SpelIndexDefinition.java b/src/main/java/org/springframework/data/redis/core/index/SpelIndexDefinition.java index 796f63eb97..771b628883 100644 --- a/src/main/java/org/springframework/data/redis/core/index/SpelIndexDefinition.java +++ b/src/main/java/org/springframework/data/redis/core/index/SpelIndexDefinition.java @@ -15,10 +15,9 @@ */ package org.springframework.data.redis.core.index; -import lombok.EqualsAndHashCode; - import org.springframework.data.redis.core.convert.SpelIndexResolver; import org.springframework.expression.spel.standard.SpelExpression; +import org.springframework.util.ObjectUtils; /** * {@link SpelIndexDefinition} defines index that is evaluated based on a {@link SpelExpression} requires the @@ -27,7 +26,6 @@ * @author Christoph Strobl * @since 1.7 */ -@EqualsAndHashCode(callSuper = true) public class SpelIndexDefinition extends RedisIndexDefinition { private final String expression; @@ -55,4 +53,24 @@ public String getExpression() { return expression; } + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + if (!super.equals(o)) + return false; + + SpelIndexDefinition that = (SpelIndexDefinition) o; + + return ObjectUtils.nullSafeEquals(expression, that.expression); + } + + @Override + public int hashCode() { + int result = super.hashCode(); + result = 31 * result + ObjectUtils.nullSafeHashCode(expression); + return result; + } } diff --git a/src/main/java/org/springframework/data/redis/core/query/DefaultSortQuery.java b/src/main/java/org/springframework/data/redis/core/query/DefaultSortQuery.java index 465b8eacf3..cabb411f3a 100644 --- a/src/main/java/org/springframework/data/redis/core/query/DefaultSortQuery.java +++ b/src/main/java/org/springframework/data/redis/core/query/DefaultSortQuery.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.core.query; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - import java.util.List; import org.springframework.data.redis.connection.SortParameters.Order; @@ -30,8 +27,6 @@ * @author Costin Leau * @author Mark Paluch */ -@Getter -@RequiredArgsConstructor class DefaultSortQuery implements SortQuery { private final K key; @@ -41,10 +36,54 @@ class DefaultSortQuery implements SortQuery { private final @Nullable String by; private final List getPattern; + DefaultSortQuery(K key, Order order, Boolean alpha, Range limit, String by, List getPattern) { + this.key = key; + this.order = order; + this.alpha = alpha; + this.limit = limit; + this.by = by; + this.getPattern = getPattern; + } + + @Override public Boolean isAlphabetic() { return alpha; } + @Override + public K getKey() { + return this.key; + } + + @Nullable + @Override + public Order getOrder() { + return this.order; + } + + @Nullable + public Boolean getAlpha() { + return this.alpha; + } + + @Nullable + @Override + public Range getLimit() { + return this.limit; + } + + @Nullable + @Override + public String getBy() { + return this.by; + } + + @Override + public List getGetPattern() { + return this.getPattern; + } + + @Override public String toString() { return "DefaultSortQuery [alpha=" + alpha + ", by=" + by + ", gets=" + getPattern + ", key=" + key + ", limit=" + limit + ", order=" + order + "]"; diff --git a/src/main/java/org/springframework/data/redis/core/types/RedisClientInfo.java b/src/main/java/org/springframework/data/redis/core/types/RedisClientInfo.java index e32eefb6a6..625c3b3b39 100644 --- a/src/main/java/org/springframework/data/redis/core/types/RedisClientInfo.java +++ b/src/main/java/org/springframework/data/redis/core/types/RedisClientInfo.java @@ -15,14 +15,13 @@ */ package org.springframework.data.redis.core.types; -import lombok.EqualsAndHashCode; - import java.io.IOException; import java.io.StringReader; import java.util.Properties; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * {@link RedisClientInfo} provides general and statistical information about client connections. @@ -30,7 +29,6 @@ * @author Christoph Strobl * @since 1.3 */ -@EqualsAndHashCode public class RedisClientInfo { public enum INFO { @@ -253,6 +251,24 @@ public String toString() { return this.clientProperties.toString(); } + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + RedisClientInfo that = (RedisClientInfo) o; + + return ObjectUtils.nullSafeEquals(clientProperties, that.clientProperties); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(clientProperties); + } + public static class RedisClientInfoBuilder { public static RedisClientInfo fromString(String source) { diff --git a/src/main/java/org/springframework/data/redis/listener/ChannelTopic.java b/src/main/java/org/springframework/data/redis/listener/ChannelTopic.java index 4b5b57f6f8..22d38d6324 100644 --- a/src/main/java/org/springframework/data/redis/listener/ChannelTopic.java +++ b/src/main/java/org/springframework/data/redis/listener/ChannelTopic.java @@ -15,9 +15,8 @@ */ package org.springframework.data.redis.listener; -import lombok.EqualsAndHashCode; - import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Channel topic implementation (maps to a Redis channel). @@ -25,7 +24,6 @@ * @author Costin Leau * @author Mark Paluch */ -@EqualsAndHashCode public class ChannelTopic implements Topic { private final String channelName; @@ -69,4 +67,22 @@ public String getTopic() { public String toString() { return channelName; } + + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + ChannelTopic that = (ChannelTopic) o; + + return ObjectUtils.nullSafeEquals(channelName, that.channelName); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(channelName); + } } diff --git a/src/main/java/org/springframework/data/redis/listener/PatternTopic.java b/src/main/java/org/springframework/data/redis/listener/PatternTopic.java index 11085bd1fd..f4d94e789f 100644 --- a/src/main/java/org/springframework/data/redis/listener/PatternTopic.java +++ b/src/main/java/org/springframework/data/redis/listener/PatternTopic.java @@ -15,9 +15,8 @@ */ package org.springframework.data.redis.listener; -import lombok.EqualsAndHashCode; - import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Pattern topic (matching multiple channels). @@ -26,7 +25,6 @@ * @author Mark Paluch * @author Christoph Strobl */ -@EqualsAndHashCode public class PatternTopic implements Topic { private final String channelPattern; @@ -70,4 +68,22 @@ public String getTopic() { public String toString() { return channelPattern; } + + @Override + public boolean equals(Object o) { + + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + PatternTopic that = (PatternTopic) o; + + return ObjectUtils.nullSafeEquals(channelPattern, that.channelPattern); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(channelPattern); + } } diff --git a/src/main/java/org/springframework/data/redis/repository/query/RedisOperationChain.java b/src/main/java/org/springframework/data/redis/repository/query/RedisOperationChain.java index 63e60adb4d..2d848d2751 100644 --- a/src/main/java/org/springframework/data/redis/repository/query/RedisOperationChain.java +++ b/src/main/java/org/springframework/data/redis/repository/query/RedisOperationChain.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.repository.query; -import lombok.EqualsAndHashCode; - import java.util.Arrays; import java.util.Collection; import java.util.Collections; @@ -28,6 +26,7 @@ import org.springframework.data.geo.Point; import org.springframework.lang.Nullable; import org.springframework.util.Assert; +import org.springframework.util.ObjectUtils; /** * Simple set of operations required to run queries against Redis. @@ -86,7 +85,6 @@ public NearPath getNear() { return near; } - @EqualsAndHashCode public static class PathAndValue { private final String path; @@ -125,6 +123,27 @@ public Object getFirstValue() { public String toString() { return path + ":" + (isSingleValue() ? getFirstValue() : values); } + + @Override + public boolean equals(Object o) { + + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + PathAndValue that = (PathAndValue) o; + + if (!ObjectUtils.nullSafeEquals(path, that.path)) { + return false; + } + return ObjectUtils.nullSafeEquals(values, that.values); + } + + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(path); + result = 31 * result + ObjectUtils.nullSafeHashCode(values); + return result; + } } /** diff --git a/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementReader.java b/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementReader.java index 8a4c64fd4a..a5869cd93b 100644 --- a/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementReader.java +++ b/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementReader.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.serializer; -import lombok.RequiredArgsConstructor; - import java.nio.ByteBuffer; import org.springframework.data.redis.util.ByteUtils; @@ -29,11 +27,14 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultRedisElementReader implements RedisElementReader { private final @Nullable RedisSerializer serializer; + DefaultRedisElementReader(RedisSerializer serializer) { + this.serializer = serializer; + } + /* (non-Javadoc) * @see org.springframework.data.redis.serializer.RedisElementReader#read(java.nio.ByteBuffer) */ diff --git a/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementWriter.java b/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementWriter.java index 2dbdd6ae65..eaed2b5439 100644 --- a/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementWriter.java +++ b/src/main/java/org/springframework/data/redis/serializer/DefaultRedisElementWriter.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.serializer; -import lombok.RequiredArgsConstructor; - import java.nio.ByteBuffer; import org.springframework.lang.Nullable; @@ -28,11 +26,14 @@ * @author Christoph Strobl * @since 2.0 */ -@RequiredArgsConstructor class DefaultRedisElementWriter implements RedisElementWriter { private final @Nullable RedisSerializer serializer; + DefaultRedisElementWriter(RedisSerializer serializer) { + this.serializer = serializer; + } + /* (non-Javadoc) * @see org.springframework.data.redis.serializer.RedisElementWriter#write(java.lang.Object) */ @@ -51,7 +52,8 @@ public ByteBuffer write(T value) { return (ByteBuffer) value; } - throw new IllegalStateException(String.format("Cannot serialize value of type %s without a serializer", value.getClass())); + throw new IllegalStateException( + String.format("Cannot serialize value of type %s without a serializer", value.getClass())); } } diff --git a/src/main/java/org/springframework/data/redis/serializer/DefaultSerializationPair.java b/src/main/java/org/springframework/data/redis/serializer/DefaultSerializationPair.java index a80ff286de..e0c9f8e793 100644 --- a/src/main/java/org/springframework/data/redis/serializer/DefaultSerializationPair.java +++ b/src/main/java/org/springframework/data/redis/serializer/DefaultSerializationPair.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.serializer; -import lombok.Getter; - import org.springframework.data.redis.serializer.RedisSerializationContext.SerializationPair; /** @@ -26,7 +24,6 @@ * @author Christoph Strobl * @since 2.0 */ -@Getter class DefaultSerializationPair implements SerializationPair { private final RedisElementReader reader; @@ -38,4 +35,14 @@ class DefaultSerializationPair implements SerializationPair { this.reader = (RedisElementReader) reader; this.writer = (RedisElementWriter) writer; } + + @Override + public RedisElementReader getReader() { + return this.reader; + } + + @Override + public RedisElementWriter getWriter() { + return this.writer; + } } diff --git a/src/main/java/org/springframework/data/redis/stream/DefaultStreamMessageListenerContainer.java b/src/main/java/org/springframework/data/redis/stream/DefaultStreamMessageListenerContainer.java index 61da8b6922..fce031f4be 100644 --- a/src/main/java/org/springframework/data/redis/stream/DefaultStreamMessageListenerContainer.java +++ b/src/main/java/org/springframework/data/redis/stream/DefaultStreamMessageListenerContainer.java @@ -15,9 +15,6 @@ */ package org.springframework.data.redis.stream; -import lombok.EqualsAndHashCode; -import lombok.RequiredArgsConstructor; - import java.time.Duration; import java.util.ArrayList; import java.util.List; @@ -37,6 +34,7 @@ import org.springframework.data.redis.core.StreamOperations; import org.springframework.util.Assert; import org.springframework.util.ErrorHandler; +import org.springframework.util.ObjectUtils; /** * Simple {@link Executor} based {@link StreamMessageListenerContainer} implementation for running {@link Task tasks} to @@ -286,12 +284,14 @@ public void remove(Subscription subscription) { * @author Mark Paluch * @since 2.2 */ - @EqualsAndHashCode - @RequiredArgsConstructor static class TaskSubscription implements Subscription { private final Task task; + protected TaskSubscription(Task task) { + this.task = task; + } + Task getTask() { return task; } @@ -322,6 +322,23 @@ public boolean await(Duration timeout) throws InterruptedException { public void cancel() throws DataAccessResourceFailureException { task.cancel(); } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + + TaskSubscription that = (TaskSubscription) o; + + return ObjectUtils.nullSafeEquals(task, that.task); + } + + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(task); + } } /** diff --git a/src/main/java/org/springframework/data/redis/stream/DefaultStreamReceiver.java b/src/main/java/org/springframework/data/redis/stream/DefaultStreamReceiver.java index eab382f1ac..d127d59ccf 100644 --- a/src/main/java/org/springframework/data/redis/stream/DefaultStreamReceiver.java +++ b/src/main/java/org/springframework/data/redis/stream/DefaultStreamReceiver.java @@ -15,7 +15,6 @@ */ package org.springframework.data.redis.stream; -import lombok.RequiredArgsConstructor; import reactor.core.CoreSubscriber; import reactor.core.publisher.Flux; import reactor.core.publisher.FluxSink; @@ -182,7 +181,6 @@ public Flux receive(Consumer consumer, StreamOffset streamOffset) { /** * A stateful Redis Stream subscription. */ - @RequiredArgsConstructor class StreamSubscription { private final Queue overflow = Queues. small().get(); @@ -192,6 +190,15 @@ class StreamSubscription { private final PollState pollState; private final BiFunction> readFunction; + protected StreamSubscription(FluxSink sink, K key, PollState pollState, + BiFunction> readFunction) { + + this.sink = sink; + this.key = key; + this.pollState = pollState; + this.readFunction = readFunction; + } + /** * Arm the subscription so {@link Subscription#request(long) demand} activates polling. */ diff --git a/src/main/java/org/springframework/data/redis/support/atomic/CompareAndSet.java b/src/main/java/org/springframework/data/redis/support/atomic/CompareAndSet.java index 722d3b4d17..4f42d1cfc8 100644 --- a/src/main/java/org/springframework/data/redis/support/atomic/CompareAndSet.java +++ b/src/main/java/org/springframework/data/redis/support/atomic/CompareAndSet.java @@ -15,8 +15,6 @@ */ package org.springframework.data.redis.support.atomic; -import lombok.RequiredArgsConstructor; - import java.util.Collection; import java.util.function.Consumer; import java.util.function.Supplier; @@ -39,7 +37,6 @@ * @see RedisAtomicInteger * @see RedisAtomicLong */ -@RequiredArgsConstructor class CompareAndSet implements SessionCallback { private final Supplier getter; @@ -48,6 +45,15 @@ class CompareAndSet implements SessionCallback { private final T expect; private final T update; + CompareAndSet(Supplier getter, Consumer setter, Object key, T expect, T update) { + + this.getter = getter; + this.setter = setter; + this.key = key; + this.expect = expect; + this.update = update; + } + /* * (non-Javadoc) * @see org.springframework.data.redis.core.SessionCallback#execute(org.springframework.data.redis.core.RedisOperations)