[ 
https://issues.apache.org/jira/browse/WICKET-6396?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16049085#comment-16049085
 ] 

Emond Papegaaij commented on WICKET-6396:
-----------------------------------------

I'm not convinced. Optionals cannot hold null (i.e. Optional.get() never 
returns null). Models can hold null. It is perfectly valid for 
IModel.getObject() to return null. To get an Optional from a IModel, you can 
always do Optional.ofNullable(model.getObject()). We could add 
IModel.toOptional(), to convert an IModel to an Optional. This also clearly 
indicates the difference in treating null.

> Model should provide other Optional's methods
> ---------------------------------------------
>
>                 Key: WICKET-6396
>                 URL: https://issues.apache.org/jira/browse/WICKET-6396
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 8.0.0-M6
>            Reporter: Kamil
>            Priority: Minor
>
> Model should provide
> {code}
> public <X extends Throwable> T orElseThrow(Supplier<? extends X> 
> exceptionSupplier) throws X;
> {code}
> {code}
> public boolean isPresent();
> {code}
> {code}
> public void ifPresent(Consumer<? super T> consumer);
> {code}
> methods for the sake of consistency with Optional API



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to