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

Sven Meier edited comment on WICKET-6412 at 7/1/17 2:39 PM:
------------------------------------------------------------

IModel is not a replacement for Optional - it defines methods to be called by 
components.

With Java 8 we decided to add default methods which make it easier to *chain* 
models.

Your proposed #orElse() would never by called by a component, so it doesn't 
belong into the interface.


was (Author: svenmeier):
IModel is not a replacement for Optional - it defines methods to be called by 
components.

With Java 8 we decided to add default methods which make it easier to *chained* 
models.

Your proposed #orElse() would never by called by a component, so it doesn't 
belong into the interface.

> Model#orElse behavior is inconsistent!
> --------------------------------------
>
>                 Key: WICKET-6412
>                 URL: https://issues.apache.org/jira/browse/WICKET-6412
>             Project: Wicket
>          Issue Type: Improvement
>    Affects Versions: 8.0.0-M6
>            Reporter: Jarosław
>            Assignee: Sven Meier
>
> Dear Wicket Devs,
> I was very confused by Model#orElse method.
> Model and Optional have similar methods and these methods behave the same:
> {code}
> Optional<Integer> _optional = Optional.ofNullable("1").map(Integer::parseInt);
> IModel<Integer> _model = Model.of("1").map(Integer::parseInt);
> {code}
> Unfortunately "orElse" behavior is totally confusing!
> {code}
> Integer integer = _optional.orElse(0);
> IModel<Integer> integerIModel = _model.orElse(0); //WRONG!
> {code}
> It should return a Model's Object instead of Model itself!
> This definitely break the least surprise rule, so can you please change that 
> before Wicket8 final release?



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

Reply via email to