Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-6412

Model#orElse behavior is inconsistent!

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 8.0.0-M6
    • 8.0.0-M7
    • None
    • None

    Description

      Dear Wicket Devs,

      I was very confused by Model#orElse method.

      Model and Optional have similar methods and these methods behave the same:

      Optional<Integer> _optional = Optional.ofNullable("1").map(Integer::parseInt);
      IModel<Integer> _model = Model.of("1").map(Integer::parseInt);
      

      Unfortunately "orElse" behavior is totally confusing!

      Integer integer = _optional.orElse(0);
      IModel<Integer> integerIModel = _model.orElse(0); //WRONG!
      

      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?

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              jarro06 Jarosław
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: