From e472cc79fa913d9719e16600158e9c5f19b8d704 Mon Sep 17 00:00:00 2001 From: jruaux Date: Thu, 6 May 2021 14:08:31 -0700 Subject: [PATCH] removed lombok @getter and @setter --- build.gradle | 5 +++ .../groovy/riot.connector-conventions.gradle | 1 - .../redislabs/riot/AbstractImportCommand.java | 8 ++--- .../redislabs/riot/AbstractTaskCommand.java | 8 ++--- .../java/com/redislabs/riot/HelpCommand.java | 8 ++--- .../main/java/com/redislabs/riot/RiotApp.java | 2 ++ .../java/com/redislabs/riot/RiotCommand.java | 10 +++--- .../com/redislabs/riot/RiotCommandLine.java | 1 - .../com/redislabs/riot/RiotStepBuilder.java | 2 +- .../CollectionToStringMapConverter.java | 31 ++++++++++--------- .../riot/convert/FieldExtractor.java | 2 +- .../convert/StreamToStringMapConverter.java | 6 ++-- .../processor/DataStructureItemProcessor.java | 19 +++++------- .../riot/redis/AbstractKeyCommand.java | 8 ++--- .../riot/redis/AbstractRedisCommand.java | 10 +++--- .../com/redislabs/riot/redis/HsetCommand.java | 8 ++--- .../com/redislabs/riot/AbstractRiotTest.java | 4 +-- 17 files changed, 65 insertions(+), 68 deletions(-) diff --git a/build.gradle b/build.gradle index d8d3aefb0..b03ba2029 100644 --- a/build.gradle +++ b/build.gradle @@ -6,6 +6,11 @@ plugins { id 'org.jreleaser' version '0.2.0' } +repositories { + mavenLocal() + mavenCentral() +} + asciidoctor { sourceDir 'docs' resources { diff --git a/buildSrc/src/main/groovy/riot.connector-conventions.gradle b/buildSrc/src/main/groovy/riot.connector-conventions.gradle index 8b385cb87..d359a36b3 100644 --- a/buildSrc/src/main/groovy/riot.connector-conventions.gradle +++ b/buildSrc/src/main/groovy/riot.connector-conventions.gradle @@ -4,7 +4,6 @@ plugins { } repositories { - mavenLocal() mavenCentral() } diff --git a/core/src/main/java/com/redislabs/riot/AbstractImportCommand.java b/core/src/main/java/com/redislabs/riot/AbstractImportCommand.java index 69fc7c9fa..39f589dd2 100644 --- a/core/src/main/java/com/redislabs/riot/AbstractImportCommand.java +++ b/core/src/main/java/com/redislabs/riot/AbstractImportCommand.java @@ -1,8 +1,8 @@ package com.redislabs.riot; import com.redislabs.riot.redis.*; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.batch.core.step.builder.AbstractTaskletStepBuilder; import org.springframework.batch.core.step.builder.SimpleStepBuilder; import org.springframework.batch.core.step.builder.StepBuilder; @@ -20,14 +20,14 @@ import java.util.function.Function; import java.util.stream.Collectors; +@Data +@EqualsAndHashCode(callSuper = true) @Command(subcommands = {EvalCommand.class, ExpireCommand.class, GeoaddCommand.class, HsetCommand.class, LpushCommand.class, NoopCommand.class, RpushCommand.class, SaddCommand.class, SetCommand.class, XaddCommand.class, ZaddCommand.class, SugaddCommand.class}, subcommandsRepeatable = true, synopsisSubcommandLabel = "[REDIS COMMAND]", commandListHeading = "Redis commands:%n") public abstract class AbstractImportCommand extends AbstractTransferCommand { /** * Initialized manually during command parsing */ - @Setter - @Getter private List> redisCommands = new ArrayList<>(); protected AbstractTaskletStepBuilder> step(StepBuilder stepBuilder, String taskName, ItemReader reader) throws Exception { diff --git a/core/src/main/java/com/redislabs/riot/AbstractTaskCommand.java b/core/src/main/java/com/redislabs/riot/AbstractTaskCommand.java index 6b1e96e5c..4e646b3f1 100644 --- a/core/src/main/java/com/redislabs/riot/AbstractTaskCommand.java +++ b/core/src/main/java/com/redislabs/riot/AbstractTaskCommand.java @@ -1,7 +1,7 @@ package com.redislabs.riot; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import org.springframework.batch.core.*; import org.springframework.batch.core.configuration.annotation.StepBuilderFactory; @@ -18,11 +18,11 @@ import java.util.function.Function; @Slf4j +@Data +@EqualsAndHashCode(callSuper = true) @CommandLine.Command public abstract class AbstractTaskCommand extends RiotCommand { - @Setter - @Getter private ExecutionStrategy executionStrategy = ExecutionStrategy.SYNC; protected final Flow flow(Step... steps) { diff --git a/core/src/main/java/com/redislabs/riot/HelpCommand.java b/core/src/main/java/com/redislabs/riot/HelpCommand.java index 3eeee0fd7..e6fe75e62 100644 --- a/core/src/main/java/com/redislabs/riot/HelpCommand.java +++ b/core/src/main/java/com/redislabs/riot/HelpCommand.java @@ -1,17 +1,13 @@ package com.redislabs.riot; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; import picocli.CommandLine; -import java.util.concurrent.Callable; - +@Data @CommandLine.Command(usageHelpAutoWidth = true) public class HelpCommand { @SuppressWarnings("unused") - @Setter - @Getter @CommandLine.Option(names = {"-H", "--help"}, usageHelp = true, description = "Show this help message and exit") private boolean helpRequested; diff --git a/core/src/main/java/com/redislabs/riot/RiotApp.java b/core/src/main/java/com/redislabs/riot/RiotApp.java index 19908c84d..dee6580e2 100644 --- a/core/src/main/java/com/redislabs/riot/RiotApp.java +++ b/core/src/main/java/com/redislabs/riot/RiotApp.java @@ -4,6 +4,7 @@ import io.netty.util.internal.logging.InternalLoggerFactory; import io.netty.util.internal.logging.JdkLoggerFactory; import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.expression.Expression; import org.springframework.expression.spel.standard.SpelExpressionParser; import picocli.CommandLine; @@ -18,6 +19,7 @@ import java.util.logging.Logger; @Data +@EqualsAndHashCode(callSuper = true) @Command(sortOptions = false, versionProvider = ManifestVersionProvider.class, subcommands = GenerateCompletionCommand.class, abbreviateSynopsis = true) public class RiotApp extends HelpCommand { diff --git a/core/src/main/java/com/redislabs/riot/RiotCommand.java b/core/src/main/java/com/redislabs/riot/RiotCommand.java index d295621b2..7a1841945 100644 --- a/core/src/main/java/com/redislabs/riot/RiotCommand.java +++ b/core/src/main/java/com/redislabs/riot/RiotCommand.java @@ -1,8 +1,8 @@ package com.redislabs.riot; import io.lettuce.core.RedisURI; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.extern.slf4j.Slf4j; import picocli.CommandLine.Command; import picocli.CommandLine.ParentCommand; @@ -10,14 +10,14 @@ import java.util.concurrent.Callable; @Slf4j +@Data +@EqualsAndHashCode(callSuper = true) @Command(abbreviateSynopsis = true, sortOptions = false) public abstract class RiotCommand extends HelpCommand implements Callable { @SuppressWarnings("unused") @ParentCommand - @Setter - @Getter - public RiotApp app; + private RiotApp app; protected RedisOptions getRedisOptions() { return app.getRedisOptions(); diff --git a/core/src/main/java/com/redislabs/riot/RiotCommandLine.java b/core/src/main/java/com/redislabs/riot/RiotCommandLine.java index 73ea5eff0..7583dc2da 100644 --- a/core/src/main/java/com/redislabs/riot/RiotCommandLine.java +++ b/core/src/main/java/com/redislabs/riot/RiotCommandLine.java @@ -8,7 +8,6 @@ public class RiotCommandLine extends CommandLine { - @Getter private final RiotApp app; private final IExecutionStrategy executionStrategy; diff --git a/core/src/main/java/com/redislabs/riot/RiotStepBuilder.java b/core/src/main/java/com/redislabs/riot/RiotStepBuilder.java index 649cffd46..a8244400e 100644 --- a/core/src/main/java/com/redislabs/riot/RiotStepBuilder.java +++ b/core/src/main/java/com/redislabs/riot/RiotStepBuilder.java @@ -39,7 +39,7 @@ public RiotStepBuilder(StepBuilder stepBuilder, TransferOptions options) { this.options = options; } - @SuppressWarnings("unchecked") + @SuppressWarnings({"unchecked", "rawtypes"}) public SimpleStepBuilder build() { SimpleStepBuilder step = stepBuilder.chunk(options.getChunkSize()).reader(reader).processor(processor).writer(writer); if (options.getProgress() != TransferOptions.Progress.NONE) { diff --git a/core/src/main/java/com/redislabs/riot/convert/CollectionToStringMapConverter.java b/core/src/main/java/com/redislabs/riot/convert/CollectionToStringMapConverter.java index df4479060..8e2a8c3fa 100644 --- a/core/src/main/java/com/redislabs/riot/convert/CollectionToStringMapConverter.java +++ b/core/src/main/java/com/redislabs/riot/convert/CollectionToStringMapConverter.java @@ -1,27 +1,28 @@ package com.redislabs.riot.convert; -import lombok.Setter; +import lombok.Builder; import org.springframework.core.convert.converter.Converter; import java.util.Collection; import java.util.HashMap; import java.util.Map; -public class CollectionToStringMapConverter> implements Converter> { +@Builder +public class CollectionToStringMapConverter implements Converter, Map> { - public static final String DEFAULT_KEY_FORMAT = "[%s]"; + public static final String DEFAULT_KEY_FORMAT = "[%s]"; - @Setter - private String keyFormat = DEFAULT_KEY_FORMAT; + @Builder.Default + private final String keyFormat = DEFAULT_KEY_FORMAT; - @Override - public Map convert(S source) { - Map result = new HashMap<>(); - int index = 0; - for (String element : source) { - result.put(String.format(keyFormat, index), element); - index++; - } - return result; - } + @Override + public Map convert(Collection source) { + Map result = new HashMap<>(); + int index = 0; + for (String element : source) { + result.put(String.format(keyFormat, index), element); + index++; + } + return result; + } } diff --git a/core/src/main/java/com/redislabs/riot/convert/FieldExtractor.java b/core/src/main/java/com/redislabs/riot/convert/FieldExtractor.java index 2882451e1..3cdf167fd 100644 --- a/core/src/main/java/com/redislabs/riot/convert/FieldExtractor.java +++ b/core/src/main/java/com/redislabs/riot/convert/FieldExtractor.java @@ -26,8 +26,8 @@ public static FieldExtractorBuilder builder() { return new FieldExtractorBuilder(); } - @Accessors(fluent = true) @Setter + @Accessors(fluent = true) public static class FieldExtractorBuilder { private String field; diff --git a/core/src/main/java/com/redislabs/riot/convert/StreamToStringMapConverter.java b/core/src/main/java/com/redislabs/riot/convert/StreamToStringMapConverter.java index b32b2d32d..175571d2a 100644 --- a/core/src/main/java/com/redislabs/riot/convert/StreamToStringMapConverter.java +++ b/core/src/main/java/com/redislabs/riot/convert/StreamToStringMapConverter.java @@ -2,19 +2,19 @@ import io.lettuce.core.StreamMessage; import lombok.Builder; -import lombok.Setter; import org.springframework.core.convert.converter.Converter; import java.util.HashMap; import java.util.List; import java.util.Map; +@Builder public class StreamToStringMapConverter implements Converter>, Map> { public static final String DEFAULT_KEY_FORMAT = "%s.%s"; - @Setter - private String keyFormat = DEFAULT_KEY_FORMAT; + @Builder.Default + private final String keyFormat = DEFAULT_KEY_FORMAT; @Override public Map convert(List> source) { diff --git a/core/src/main/java/com/redislabs/riot/processor/DataStructureItemProcessor.java b/core/src/main/java/com/redislabs/riot/processor/DataStructureItemProcessor.java index 3985b5765..f73cf0063 100644 --- a/core/src/main/java/com/redislabs/riot/processor/DataStructureItemProcessor.java +++ b/core/src/main/java/com/redislabs/riot/processor/DataStructureItemProcessor.java @@ -10,23 +10,20 @@ import org.springframework.core.convert.converter.Converter; import org.springframework.util.Assert; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; public class DataStructureItemProcessor implements ItemProcessor, Map> { private final Converter> keyFieldsExtractor; private final Converter, Map> hashConverter; private final Converter>, Map> streamConverter; - private final Converter, Map> listConverter; - private final Converter, Map> setConverter; + private final Converter, Map> listConverter; + private final Converter, Map> setConverter; private final Converter>, Map> zsetConverter; private final Converter> stringConverter; private final Converter> defaultConverter; - public DataStructureItemProcessor(Converter> keyFieldsExtractor, Converter, Map> hashConverter, Converter, Map> listConverter, Converter, Map> setConverter, Converter>, Map> streamConverter, Converter> stringConverter, Converter>, Map> zsetConverter, Converter> defaultConverter) { + public DataStructureItemProcessor(Converter> keyFieldsExtractor, Converter, Map> hashConverter, Converter, Map> listConverter, Converter, Map> setConverter, Converter>, Map> streamConverter, Converter> stringConverter, Converter>, Map> zsetConverter, Converter> defaultConverter) { this.keyFieldsExtractor = keyFieldsExtractor; this.hashConverter = hashConverter; this.listConverter = listConverter; @@ -81,8 +78,8 @@ public static DataStructureItemProcessorBuilder builder() { return new DataStructureItemProcessorBuilder(); } - @Accessors(fluent = true) @Setter + @Accessors(fluent = true) public static class DataStructureItemProcessorBuilder { private String keyRegex; @@ -90,9 +87,9 @@ public static class DataStructureItemProcessorBuilder { public DataStructureItemProcessor build() { Assert.notNull(keyRegex, "Key regex is required."); RegexNamedGroupsExtractor keyFieldsExtractor = RegexNamedGroupsExtractor.builder().regex(keyRegex).build(); - StreamToStringMapConverter streamConverter = new StreamToStringMapConverter(); - CollectionToStringMapConverter> listConverter = new CollectionToStringMapConverter<>(); - CollectionToStringMapConverter> setConverter = new CollectionToStringMapConverter<>(); + StreamToStringMapConverter streamConverter = StreamToStringMapConverter.builder().build(); + CollectionToStringMapConverter listConverter = CollectionToStringMapConverter.builder().build(); + CollectionToStringMapConverter setConverter = CollectionToStringMapConverter.builder().build(); ZsetToStringMapConverter zsetConverter = new ZsetToStringMapConverter(); Converter> stringConverter = new StringToStringMapConverter(); return new DataStructureItemProcessor(keyFieldsExtractor, c -> c, listConverter, setConverter, streamConverter, stringConverter, zsetConverter, c -> null); diff --git a/core/src/main/java/com/redislabs/riot/redis/AbstractKeyCommand.java b/core/src/main/java/com/redislabs/riot/redis/AbstractKeyCommand.java index 5fa7aa23a..b3c60c1d0 100644 --- a/core/src/main/java/com/redislabs/riot/redis/AbstractKeyCommand.java +++ b/core/src/main/java/com/redislabs/riot/redis/AbstractKeyCommand.java @@ -1,5 +1,7 @@ package com.redislabs.riot.redis; +import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.Setter; import org.springframework.batch.item.redis.support.operation.AbstractKeyOperation; @@ -8,15 +10,13 @@ import java.util.Map; +@Data +@EqualsAndHashCode(callSuper = true) @CommandLine.Command public abstract class AbstractKeyCommand extends AbstractRedisCommand> { - @Setter - @Getter @Option(names = {"-p", "--keyspace"}, description = "Keyspace prefix", paramLabel = "") private String keyspace = ""; - @Setter - @Getter @Option(names = {"-k", "--keys"}, arity = "1..*", description = "Key fields", paramLabel = "") private String[] keys; diff --git a/core/src/main/java/com/redislabs/riot/redis/AbstractRedisCommand.java b/core/src/main/java/com/redislabs/riot/redis/AbstractRedisCommand.java index ff979808d..2bc0852a6 100644 --- a/core/src/main/java/com/redislabs/riot/redis/AbstractRedisCommand.java +++ b/core/src/main/java/com/redislabs/riot/redis/AbstractRedisCommand.java @@ -6,8 +6,8 @@ import com.redislabs.riot.convert.FieldExtractor; import com.redislabs.riot.convert.ObjectToNumberConverter; import com.redislabs.riot.convert.ObjectToStringConverter; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.batch.item.redis.support.KeyMaker; import org.springframework.core.convert.converter.Converter; import org.springframework.util.ObjectUtils; @@ -15,16 +15,14 @@ import java.util.Map; +@Data +@EqualsAndHashCode(callSuper = true) @CommandLine.Command(sortOptions = false, abbreviateSynopsis = true) public abstract class AbstractRedisCommand extends HelpCommand implements RedisCommand { - @Setter - @Getter @CommandLine.Option(names = {"-s", "--separator"}, description = "Key separator (default: ${DEFAULT-VALUE})", paramLabel = "") private String keySeparator = ":"; @SuppressWarnings("unused") - @Setter - @Getter @CommandLine.Option(names = {"-r", "--remove"}, description = "Remove key or member fields the first time they are used") private boolean removeFields; diff --git a/core/src/main/java/com/redislabs/riot/redis/HsetCommand.java b/core/src/main/java/com/redislabs/riot/redis/HsetCommand.java index dd7199d90..2abb26c6f 100644 --- a/core/src/main/java/com/redislabs/riot/redis/HsetCommand.java +++ b/core/src/main/java/com/redislabs/riot/redis/HsetCommand.java @@ -1,18 +1,18 @@ package com.redislabs.riot.redis; -import lombok.Getter; -import lombok.Setter; +import lombok.Data; +import lombok.EqualsAndHashCode; import org.springframework.batch.item.redis.RedisOperation; import picocli.CommandLine; import picocli.CommandLine.Command; import java.util.Map; +@Data +@EqualsAndHashCode(callSuper = true) @Command(name = "hset", aliases = "hmset", description = "Set hashes from input") public class HsetCommand extends AbstractKeyCommand { - @Setter - @Getter @CommandLine.Mixin private FilteringOptions filtering = new FilteringOptions(); diff --git a/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java b/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java index ced5e3c9a..493fb409a 100644 --- a/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java +++ b/test/src/main/java/com/redislabs/riot/AbstractRiotTest.java @@ -11,6 +11,7 @@ import java.nio.charset.Charset; import java.util.function.Consumer; +@SuppressWarnings("unchecked") public abstract class AbstractRiotTest { protected abstract RiotApp app(); @@ -26,8 +27,7 @@ protected String[] args(String filename) throws Exception { } } - protected int - execute(String filename, RedisContainer container, Consumer... configurators) throws Exception { + protected int execute(String filename, RedisContainer container, Consumer... configurators) throws Exception { RiotApp app = app(); RiotCommandLine commandLine = app.commandLine(); CommandLine.ParseResult parseResult = commandLine.parseArgs(args(filename));