You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by GitBox <gi...@apache.org> on 2022/02/21 09:08:50 UTC

[GitHub] [thrift] Jimexist opened a new pull request #2524: add support for converting to java optional

Jimexist opened a new pull request #2524:
URL: https://github.com/apache/thrift/pull/2524


   <!-- Explain the changes in the pull request below: -->
     
   
   <!-- We recommend you review the checklist/tips before submitting a pull request. -->
   
   - [ ] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket?  (not required for trivial changes)
   - [ ] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
   - [ ] Did you squash your changes to a single commit?  (not required, but preferred)
   - [ ] Did you do your best to avoid breaking changes?  If one was needed, did you label the Jira ticket with "Breaking-Change"?
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


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

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



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

Posted by GitBox <gi...@apache.org>.
ctubbsii commented on a change in pull request #2524:
URL: https://github.com/apache/thrift/pull/2524#discussion_r818286243



##########
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:
       Could also do:
   
   ```suggestion
           return Optional.ofNullable(isDefined() ? get() : null);
   ```




-- 
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



[GitHub] [thrift] Jens-G merged pull request #2524: THRIFT-5520 [java lib] add support for converting to java optional

Posted by GitBox <gi...@apache.org>.
Jens-G merged pull request #2524:
URL: https://github.com/apache/thrift/pull/2524


   


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

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



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

Posted by GitBox <gi...@apache.org>.
Jimexist commented on pull request #2524:
URL: https://github.com/apache/thrift/pull/2524#issuecomment-1046900529


   as a follow up, see:
   - https://github.com/apache/thrift/pull/2525 


-- 
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



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

Posted by GitBox <gi...@apache.org>.
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