Skip to content

Commit c95f71c

Browse files
committed
Tidy HttpClientRequest javadoc, refactor internal method in ClientMethodWriter
1 parent c3fad7e commit c95f71c

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

http-client/src/main/java/io/avaje/http/client/HttpClientRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ default HttpClientRequest queryParam(String name, Collection<String> values) {
367367
/**
368368
* Set the body content with supplied InputStream.
369369
*
370-
* @param supplier The InputStream content to send as body content
370+
* @param stream The InputStream content to send as body content
371371
* @return The request being built
372372
*/
373373
HttpClientRequest body(InputStream stream);

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

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -253,34 +253,34 @@ private void writeFormParam(MethodParam param, ParamType paramType) {
253253

254254
private void writeBody() {
255255
for (MethodParam param : method.params()) {
256-
ParamType paramType = param.paramType();
257-
258-
if (paramType == ParamType.BODY) {
259-
256+
if (param.paramType() == ParamType.BODY) {
260257
var type = param.utype().full();
261-
if ("java.net.http.HttpRequest.BodyPublisher".equals(type)
262-
|| "java.lang.String".equals(type)
263-
|| "byte[]".equals(type)
264-
|| "java.io.InputStream".equals(type)
265-
|| "java.util.function.Supplier<?extendsjava.io.InputStream>".equals(type)
266-
|| "java.util.function.Supplier<java.io.InputStream>".equals(type)
267-
|| "java.nio.file.Path".equals(type)
268-
|| "io.avaje.http.client.BodyContent".equals(type)) {
269-
258+
if (directBodyType(type)) {
270259
writer.append(" .body(%s)", param.name()).eol();
271-
272260
} else {
273-
274261
writer.append(" .body(%s, ", param.name());
275262
writeGeneric(param.utype());
276263
writer.append(")").eol();
277264
}
278-
279265
return;
280266
}
281267
}
282268
}
283269

270+
/**
271+
* Return true for body types that are directly supported.
272+
*/
273+
private static boolean directBodyType(String type) {
274+
return "java.net.http.HttpRequest.BodyPublisher".equals(type)
275+
|| "java.lang.String".equals(type)
276+
|| "byte[]".equals(type)
277+
|| "java.io.InputStream".equals(type)
278+
|| "java.util.function.Supplier<?extendsjava.io.InputStream>".equals(type)
279+
|| "java.util.function.Supplier<java.io.InputStream>".equals(type)
280+
|| "java.nio.file.Path".equals(type)
281+
|| "io.avaje.http.client.BodyContent".equals(type);
282+
}
283+
284284
private void writePaths(Set<PathSegments.Segment> segments) {
285285
if (!segments.isEmpty()) {
286286
writer.append(" ");

0 commit comments

Comments
 (0)