Skip to content

Commit 251568f

Browse files
committed
Use prism utils
1 parent a295e3d commit 251568f

File tree

3 files changed

+4
-32
lines changed

3 files changed

+4
-32
lines changed

http-generator-client/src/main/java/io/avaje/http/generator/client/ComponentMetaData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ String fullName() {
3535
System.err.println("ComponentMetaData detected top package: " + topPackage + " defaultPackage:" + defaultPackage);
3636
fullName =
3737
defaultPackage
38-
? name(topPackage) + "HttpComponent"
38+
? "DefaultHttpComponent"
3939
: topPackage + "." + name(topPackage) + "HttpComponent";
4040
}
4141
return fullName;

http-generator-client/src/main/java/io/avaje/http/generator/client/SimpleComponentWriter.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
11
package io.avaje.http.generator.client;
22

3-
import static io.avaje.http.generator.core.ProcessingContext.createMetaInfWriter;
43
import static io.avaje.http.generator.core.ProcessingContext.createWriter;
54

65
import java.io.IOException;
76
import java.util.List;
87
import java.util.Set;
98
import java.util.TreeSet;
109

11-
import javax.tools.FileObject;
1210
import javax.tools.JavaFileObject;
1311

1412
import io.avaje.http.generator.core.Append;
15-
import io.avaje.http.generator.core.Constants;
1613
import io.avaje.http.generator.core.Util;
1714

1815
final class SimpleComponentWriter {
@@ -98,7 +95,8 @@ private void writeImports() {
9895
}
9996

10097
private void writePackage() {
101-
final String packageName = TopPackage.packageOf(fullName);
98+
final String packageName =
99+
"DefaultHttpComponent".equals(fullName) ? "" : ProcessorUtils.packageOf(fullName);
102100
if (!packageName.isEmpty()) {
103101
writer.append("package %s;", packageName).eol().eol();
104102
}

http-generator-client/src/main/java/io/avaje/http/generator/client/TopPackage.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,7 @@ private String value() {
1616

1717
private TopPackage(Collection<String> values) {
1818
for (final String pkg : values) {
19-
topPackage = commonParent(topPackage, pkg);
19+
topPackage = ProcessorUtils.commonParent(topPackage, pkg);
2020
}
2121
}
22-
23-
/** Return the common parent package. */
24-
static String commonParent(String currentTop, String aPackage) {
25-
if (aPackage == null) return currentTop;
26-
if (currentTop == null) return packageOf(aPackage);
27-
if (aPackage.startsWith(currentTop)) {
28-
return currentTop;
29-
}
30-
int next;
31-
do {
32-
next = currentTop.lastIndexOf('.');
33-
if (next > -1) {
34-
currentTop = currentTop.substring(0, next);
35-
if (aPackage.startsWith(currentTop)) {
36-
return currentTop;
37-
}
38-
}
39-
} while (next > -1);
40-
41-
return currentTop;
42-
}
43-
44-
static String packageOf(String cls) {
45-
final int pos = cls.lastIndexOf('.');
46-
return (pos == -1) ? "" : cls.substring(0, pos);
47-
}
4822
}

0 commit comments

Comments
 (0)