aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
author zaaarf <me@zaaarf.foo>2024-01-23 12:07:00 +0100
committer zaaarf <me@zaaarf.foo>2024-01-23 12:07:00 +0100
commit145040c2c665943bf096ce6253e250e2ddd47ac7 (patch)
treeb7bf063bdc179874fe277a09997e4297f2e6f44e /src/main
parent9fc99e23d8c9ec50a7dd0ff7f29b5ce35c2f8cac (diff)
fix: optional get default0.1.2
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/foo/zaaarf/routecompass/RouteCompass.java9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/main/java/foo/zaaarf/routecompass/RouteCompass.java b/src/main/java/foo/zaaarf/routecompass/RouteCompass.java
index b5a6b3f..7c34739 100644
--- a/src/main/java/foo/zaaarf/routecompass/RouteCompass.java
+++ b/src/main/java/foo/zaaarf/routecompass/RouteCompass.java
@@ -61,7 +61,6 @@ public class RouteCompass extends AbstractProcessor {
* @return false, letting other processor process the annotations again
*/
@Override
- @SuppressWarnings("OptionalGetWithoutIsPresent")
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment env) {
for(TypeElement annotationType : annotations) {
env.getElementsAnnotatedWith(annotationType)
@@ -80,7 +79,7 @@ public class RouteCompass extends AbstractProcessor {
this.getDTO(this.processingEnv.getTypeUtils().asElement(elem.getReturnType())),
this.getDTO(elem.getParameters().stream()
.filter(e -> e.getAnnotation(RequestBody.class) != null)
- .findFirst().get()),
+ .findFirst().orElse(null)),
this.getQueryParams(elem.getParameters())
));
});
@@ -100,10 +99,10 @@ public class RouteCompass extends AbstractProcessor {
out.print("\t- ");
if(r.deprecated) out.print("[DEPRECATED] ");
out.print(r.method + " " + r.path);
- if(r.consumes != null) {
+ if(r.consumes != null && r.consumes.length > 0)
out.print("(expects: " + Arrays.toString(r.consumes) + ")");
- }
- if(r.produces != null) out.print("(returns: " + Arrays.toString(r.produces) + ")");
+ if(r.produces != null && r.produces.length > 0)
+ out.print("(returns: " + Arrays.toString(r.produces) + ")");
out.println();
BiConsumer<String, Route.Param[]> printParam = (name, params) -> {