[ https://issues.apache.org/jira/browse/JDO-751?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15314463#comment-15314463 ]
Tilmann Zäschke commented on JDO-751: ------------------------------------- While writing the unit test, I came up with the following test cases for {{orElse}}: {code:title=SupportedOptionalMethods.java|borderStyle=solid} public void testOrElse() { OptionalSample otherPC = new OptionalSample(); otherPC.setId(33); String paramDecl = OptionalSample.class.getName() + " otherPCparam"; Object[] params = new Object[]{otherPC}; checkQuery("this.optionalPC.orElse(otherPCparam) == null", paramDecl, params, new Object[]{}); checkQuery("this.optionalPC.orElse(otherPCparam) != otherPCparam", paramDecl, params, new Object[]{oidPC}); paramDecl = "Date myDate, Date otherDate"; checkQuery("this.optionalDate.orElse(otherDate) == myDate", paramDecl, new Object[]{DATE, DATE2}, new Object[]{oidPC}); paramDecl = "Date otherDate"; checkQuery("this.optionalString.orElse(otherDate) == otherDate", paramDecl, new Object[]{oidNull, oidEmpty, oidDummyPC}); checkQuery("this.optionalString.orElse(12345) == " + INTEGER, new Object[]{oidPC}); checkQuery("this.optionalString.orElse(12345) == 12345", new Object[]{oidNull, oidEmpty, oidDummyPC}); paramDecl = String.class.getName() + " myString"; checkQuery("this.optionalString.orElse(`xyz`) == otherString", paramDecl, new Object[]{STRING}, new Object[]{oidPC}); checkQuery("this.optionalString.orElse(`xyz`) == `xyz`", new Object[]{oidNull, oidEmpty, oidDummyPC}); } {code} The main problem is that all of these tests seem somewhat artificial. Can anyone suggest some real-world cases for using {{orElse}} in queries? Otherwise it may make sense to drop support support for {{orElse}} for now, until we see a need. > Support for Java8 Optional > -------------------------- > > Key: JDO-751 > URL: https://issues.apache.org/jira/browse/JDO-751 > Project: JDO > Issue Type: New Feature > Components: specification, tck > Reporter: Andy Jefferson > Fix For: JDO 3.2 > > Attachments: JDO-751-tck-patch-v2.txt > > > java.util.Optional provides a feature that is available in other languages. > Since JDO 3.2 will be for Java8+ then it makes sense to add support for this > as a "supported persistable type" -- This message was sent by Atlassian JIRA (v6.3.4#6332)