chibenwa commented on code in PR #2991:
URL: https://github.com/apache/james-project/pull/2991#discussion_r3055638603


##########
event-bus/api/src/main/java/org/apache/james/events/DeserializationResult.java:
##########
@@ -22,33 +22,67 @@
 import java.util.List;
 import java.util.Optional;
 
-public sealed interface DeserializationResult permits 
DeserializationResult.Success, DeserializationResult.Failure {
+import com.google.common.collect.ImmutableList;
+
+public sealed interface DeserializationResult permits 
DeserializationResult.Success, DeserializationResult.SuccessList, 
DeserializationResult.Failure {
     static DeserializationResult of(Optional<Event> maybeEvent, String 
throwingMessage) {
         return maybeEvent.<DeserializationResult>map(Success::new)
             .orElse(new Failure(throwingMessage));
     }
 
-    static boolean isSuccessEventList(List<DeserializationResult> results) {
-        return !results.isEmpty() && results.getFirst().isSuccess();
+    static DeserializationResult ofList(Optional<List<Event>> maybeEvents, 
String throwingMessage) {
+        return maybeEvents.<DeserializationResult>map(SuccessList::new)
+            .orElse(new Failure(throwingMessage));
     }
 
     Event event();
 
+    List<Event> events();
+
     default boolean isSuccess() {
         return this instanceof Success;
     }
 
+    default boolean isSuccessList() {
+        return this instanceof SuccessList;
+    }

Review Comment:
   Can't we have only one isSuccess method ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to