You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@thrift.apache.org by GitBox <gi...@apache.org> on 2022/03/03 06:45:47 UTC

[GitHub] [thrift] Jimexist commented on a change in pull request #2524: THRIFT-5520 [java lib] add support for converting to java optional

Jimexist commented on a change in pull request #2524:
URL: https://github.com/apache/thrift/pull/2524#discussion_r818358411



##########
File path: lib/java/src/org/apache/thrift/Option.java
##########
@@ -54,6 +56,19 @@ public T or(T other) {
             return other;
         }
     }
+
+    /**
+     * Turn this Option into Java 8 Optional type
+     * @return Java 8+ Optional Type
+     */
+    public Optional<T> toOptional() {
+        if (isDefined()) {
+            return Optional.of(get());
+        } else {
+            return Optional.empty();
+        }

Review comment:
       I'd keep this as is because it is more explicit while the proposed change results in two if-comparison, one in here and another in the optional class itself 




-- 
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: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org