Răsfoiți Sursa

Changes to fortunes.

Signed-off-by: Santiago Pericas-Geertsen <[email protected]>
Santiago Pericas-Geertsen 10 luni în urmă
părinte
comite
a7deef0705

+ 5 - 1
frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/models/Fortune.java

@@ -1,7 +1,7 @@
 
 package io.helidon.benchmark.nima.models;
 
-public final class Fortune {
+public final class Fortune implements Comparable<Fortune> {
     public int id;
     public String message;
 
@@ -17,4 +17,8 @@ public final class Fortune {
     public String getMessage() {
         return message;
     }
+    @Override
+    public int compareTo(Fortune other) {
+        return message.compareTo(other.message);
+    }
 }

+ 2 - 2
frameworks/Java/helidon/nima/src/main/java/io/helidon/benchmark/nima/services/FortuneHandler.java

@@ -1,7 +1,7 @@
 
 package io.helidon.benchmark.nima.services;
 
-import java.util.Comparator;
+import java.util.Collections;
 import java.util.List;
 
 import com.fizzed.rocker.runtime.ArrayOfByteArraysOutput;
@@ -32,7 +32,7 @@ public class FortuneHandler implements Handler {
         res.header(CONTENT_TYPE_HTML);
         List<Fortune> fortuneList = repository.getFortunes();
         fortuneList.add(ADDITIONAL_FORTUNE);
-        fortuneList.sort(Comparator.comparing(Fortune::getMessage));
+        Collections.sort(fortuneList);
         res.send(fortunes.template(fortuneList)
                 .render(ArrayOfByteArraysOutput.FACTORY)
                 .toByteArray());