From 0bcbf1aa28cefc0efaf03bd233a2d4f1a424abe5 Mon Sep 17 00:00:00 2001 From: Josiah Noel <32279667+SentryMan@users.noreply.github.com> Date: Fri, 20 Oct 2023 15:31:05 -0400 Subject: [PATCH] prevent duplicate constants --- .../io/avaje/http/generator/client/ClientMethodWriter.java | 7 +++++++ .../io/avaje/http/generator/client/clients/TitanFall.java | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java b/http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java index 32b6cc49..ee5d93e3 100644 --- a/http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java +++ b/http-generator-client/src/main/java/io/avaje/http/generator/client/ClientMethodWriter.java @@ -9,6 +9,7 @@ import static java.util.stream.Collectors.toMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Optional; @@ -35,6 +36,7 @@ class ClientMethodWriter { private final Optional timeout; private final boolean useConfig; private final Map segmentPropertyMap; + private final Set propertyConstants = new HashSet<>(); ClientMethodWriter(MethodReader method, Append writer, boolean useJsonb) { this.method = method; @@ -76,6 +78,11 @@ private void methodStart(Append writer) { segmentPropertyMap.forEach( (k, v) -> { + + if (!propertyConstants.add(v)) { + return; + } + writer.append(" private static final String %s = ", v); final String getProperty = useConfig ? "Config.get(" : "System.getProperty("; writer.append(getProperty).append("\"%s\");", k).eol(); diff --git a/http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java b/http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java index 21b542e7..918c685f 100644 --- a/http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java +++ b/http-generator-client/src/test/java/io/avaje/http/generator/client/clients/TitanFall.java @@ -7,5 +7,9 @@ public interface TitanFall { @Get("/${titan}/${drop.point}") - Titan titanfall(); + Titan titanFall(); + + + @Get("/${titan}/copium") + Titan titanFall3(); } \ No newline at end of file