Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ private BodyAdapter defaultBodyAdapter() {
.orElseGet(() -> {
try {
return new JsonbBodyAdapter();
} catch (NoClassDefFoundError e) {
} catch (Throwable e) {
// I guess it don't exist
}
try {
return new JacksonBodyAdapter();
} catch (NoClassDefFoundError e) {
} catch (Throwable e) {
return bodyAdapter;
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ String fullName() {
String topPackage = TopPackage.of(generatedClients);

var defaultPackage =
!topPackage.contains(".")
&& APContext.getProjectModuleElement().isUnnamed()
&& APContext.elements().getPackageElement(topPackage) == null;

!topPackage.contains(".")
&& APContext.getProjectModuleElement().isUnnamed()
&& APContext.elements().getPackageElement(topPackage) == null;
fullName =
defaultPackage
? name(topPackage) + "HttpComponent"
: topPackage + "." + name(topPackage) + "HttpComponent";
defaultPackage
? "DefaultHttpComponent"
: topPackage + "." + name(topPackage) + "HttpComponent";
}
return fullName;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
package io.avaje.http.generator.client;

import static io.avaje.http.generator.core.ProcessingContext.createMetaInfWriter;
import static io.avaje.http.generator.core.ProcessingContext.createWriter;

import java.io.IOException;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import javax.tools.FileObject;
import javax.tools.JavaFileObject;

import io.avaje.http.generator.core.Append;
import io.avaje.http.generator.core.Constants;
import io.avaje.http.generator.core.Util;

final class SimpleComponentWriter {
Expand Down Expand Up @@ -98,7 +95,8 @@ private void writeImports() {
}

private void writePackage() {
final String packageName = TopPackage.packageOf(fullName);
final String packageName =
"DefaultHttpComponent".equals(fullName) ? "" : ProcessorUtils.packageOf(fullName);
if (!packageName.isEmpty()) {
writer.append("package %s;", packageName).eol().eol();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,7 @@ private String value() {

private TopPackage(Collection<String> values) {
for (final String pkg : values) {
topPackage = commonParent(topPackage, pkg);
topPackage = ProcessorUtils.commonParent(topPackage, pkg);
}
}

/** Return the common parent package. */
static String commonParent(String currentTop, String aPackage) {
if (aPackage == null) return currentTop;
if (currentTop == null) return packageOf(aPackage);
if (aPackage.startsWith(currentTop)) {
return currentTop;
}
int next;
do {
next = currentTop.lastIndexOf('.');
if (next > -1) {
currentTop = currentTop.substring(0, next);
if (aPackage.startsWith(currentTop)) {
return currentTop;
}
}
} while (next > -1);

return currentTop;
}

static String packageOf(String cls) {
final int pos = cls.lastIndexOf('.');
return (pos == -1) ? "" : cls.substring(0, pos);
}
}