Skip to content

Commit ec4f84d

Browse files
committed
Format only changes
1 parent 27e618c commit ec4f84d

File tree

6 files changed

+19
-44
lines changed

6 files changed

+19
-44
lines changed

http-api/src/main/java/io/avaje/http/api/context/RequestContextResolver.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ public interface RequestContextResolver {
1414
/**
1515
* Wraps the execution of the given callable in request context processing.
1616
*
17-
* @param ctx The request context
17+
* @param ctx The request context
1818
* @param callable The callable
19-
* @param <T> The return type of the callable
19+
* @param <T> The return type of the callable
2020
* @return The return value of the callable
2121
* @throws Exception if the callable throws an exception
2222
*/
@@ -25,20 +25,20 @@ public interface RequestContextResolver {
2525
/**
2626
* Wraps the execution of the given supplier in request context processing.
2727
*
28-
* @param ctx The request context
28+
* @param ctx The request context
2929
* @param supplier The supplier
30-
* @param <T> The return type of the supplier
30+
* @param <T> The return type of the supplier
3131
* @return The return value of the supplier
3232
*/
3333
<T> T supplyWith(ServerContext ctx, Supplier<T> supplier);
3434

3535
/**
3636
* Wraps the execution of the given runnable in request context processing.
3737
*
38-
* @param ctx The request context
38+
* @param ctx The request context
3939
* @param runnable The runnable
4040
*/
41-
void runWith(ServerContext request, Runnable runnable);
41+
void runWith(ServerContext ctx, Runnable runnable);
4242

4343
/**
4444
* Retrieve the current server context.

http-api/src/main/java/io/avaje/http/api/context/ServerContext.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
11
package io.avaje.http.api.context;
22

3-
/** Holder for the Server Request/Response Classes */
4-
public class ServerContext {
3+
/**
4+
* Holder for the Server Request/Response instances.
5+
*/
6+
public final class ServerContext {
57

68
private final Object request;
79
private final Object response;
810

9-
public ServerContext(Object req, Object res) {
10-
request = req;
11-
response = res;
11+
public ServerContext(Object request, Object response) {
12+
this.request = request;
13+
this.response = response;
1214
}
1315

1416
/**
1517
* Retrieve the current server request.
1618
*
1719
* @return The request
1820
*/
21+
@SuppressWarnings("unchecked")
1922
<T> T request() {
2023
return (T) request;
2124
}
@@ -25,6 +28,7 @@ <T> T request() {
2528
*
2629
* @return The request
2730
*/
31+
@SuppressWarnings("unchecked")
2832
<T> T response() {
2933
return (T) response;
3034
}

http-generator-core/src/main/java/io/avaje/http/generator/core/MethodReader.java

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public class MethodReader {
7070

7171
initWebMethodViaAnnotation();
7272

73-
this.superMethods =
74-
superMethods(element.getEnclosingElement(), element.getSimpleName().toString());
73+
this.superMethods = superMethods(element.getEnclosingElement(), element.getSimpleName().toString());
7574
superMethods.forEach(m -> methodRoles.addAll(Util.findRoles(m)));
7675
this.hasThrows = !element.getThrownTypes().isEmpty();
7776
this.securityRequirements = readSecurityRequirements();
@@ -103,7 +102,6 @@ private boolean initResolver() {
103102
private boolean hasInstrument(Element e) {
104103
for (final var a : e.getAnnotationMirrors()) {
105104
if (HttpMethodPrism.isPresent(a.getAnnotationType().asElement())) {
106-
107105
return a.getElementValues().values().stream().anyMatch(v -> v.getValue().equals(true));
108106
}
109107
}
@@ -143,7 +141,6 @@ public String toString() {
143141
}
144142

145143
private void initWebMethodViaAnnotation() {
146-
147144
if (findAnnotation(FormPrism::getOptionalOn).isPresent()) {
148145
this.formMarker = true;
149146
}
@@ -207,7 +204,6 @@ private void readSecurityRequirements(Element element, List<SecurityRequirementP
207204
}
208205

209206
private List<OpenAPIResponsePrism> buildApiResponses() {
210-
211207
final var container =
212208
findAnnotation(OpenAPIResponsesPrism::getOptionalOn).stream()
213209
.map(OpenAPIResponsesPrism::value)
@@ -226,11 +222,8 @@ private List<OpenAPIResponsePrism> buildApiResponses() {
226222
.flatMap(List::stream),
227223
OpenAPIResponsePrism.getAllInstancesOn(method).stream()));
228224

229-
final var responses =
230-
Stream.concat(methodResponses, superMethodResponses).collect(Collectors.toList());
231-
225+
final var responses = Stream.concat(methodResponses, superMethodResponses).collect(Collectors.toList());
232226
responses.addAll(bean.openApiResponses());
233-
234227
return responses;
235228
}
236229

@@ -239,7 +232,6 @@ public <A> Optional<A> findAnnotation(Function<Element, Optional<A>> prismFunc)
239232
}
240233

241234
public <A> Optional<A> findAnnotation(Function<Element, Optional<A>> prismFunc, ExecutableElement elem) {
242-
243235
return prismFunc.apply(elem).or(() -> bean.findMethodAnnotation(prismFunc, elem));
244236
}
245237

@@ -249,9 +241,7 @@ private List<String> addTagsToList(Element element, List<String> list) {
249241
}
250242

251243
TagPrism.getAllInstancesOn(element).forEach(t -> list.add(t.name()));
252-
253244
final var tags = TagsPrism.getInstanceOn(element);
254-
255245
if (tags != null) {
256246
for (final var tag : tags.value()) {
257247
list.add(tag.name());
@@ -418,21 +408,14 @@ public boolean instrumentContext() {
418408
return instrumentContext;
419409
}
420410

421-
public void writeContext(Append writer, String reqName,String resName) {
422-
411+
public void writeContext(Append writer, String reqName, String resName) {
423412
if (isVoid) {
424-
425413
writer.append("resolver.runWith");
426-
427414
} else if (hasThrows) {
428-
429415
writer.append("resolver.callWith");
430-
431416
} else {
432-
433417
writer.append("resolver.supplyWith");
434418
}
435-
436419
writer.append("(new ServerContext(%s, %s), () -> ", reqName, resName);
437420
}
438421
}

http-generator-javalin/src/main/java/io/avaje/http/generator/javalin/ControllerMethodWriter.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class ControllerMethodWriter {
3131
}
3232

3333
void write(boolean requestScoped) {
34-
3534
final var segments = method.pathSegments();
3635
final var fullPath = segments.fullPath();
3736

@@ -76,12 +75,10 @@ void write(boolean requestScoped) {
7675
}
7776

7877
if (instrumentContext) {
79-
8078
writer.append(")");
8179
}
8280

8381
writer.append(");").eol();
84-
8582
if (!method.isVoid()) {
8683
writeContextReturn();
8784
writer.eol();
@@ -133,7 +130,6 @@ private void writeContextReturn(final String resultVariableName) {
133130
if ("java.util.concurrent.CompletableFuture".equals(uType.mainType())) {
134131
uType = uType.paramRaw();
135132
}
136-
137133
writer.append(" %sJsonType.toJson(%s, ctx.contentType(\"application/json\").outputStream());", uType.shortName(), resultVariableName);
138134
} else {
139135
writer.append(" ctx.json(%s);", resultVariableName);

http-generator-jex/src/main/java/io/avaje/http/generator/jex/ControllerMethodWriter.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class ControllerMethodWriter {
2929
}
3030

3131
void write(boolean requestScoped) {
32-
3332
final PathSegments segments = method.pathSegments();
3433
final String fullPath = segments.fullPath();
3534

tests/test-javalin-jsonb/src/main/resources/public/openapi.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,14 +1245,7 @@
12451245
},
12461246
"responses" : {
12471247
"200" : {
1248-
"description" : "",
1249-
"content" : {
1250-
"application/json" : {
1251-
"schema" : {
1252-
"type" : "string"
1253-
}
1254-
}
1255-
}
1248+
"description" : "No content"
12561249
}
12571250
}
12581251
}

0 commit comments

Comments
 (0)