Repository: wicket
Updated Branches:
  refs/heads/master 3729285d0 -> 019b002da


WICKET-6203 rework IModel#mapWith


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/a0c43bb9
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/a0c43bb9
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/a0c43bb9

Branch: refs/heads/master
Commit: a0c43bb9808c5e6b916e6461b357c3eaa4fa84fc
Parents: 0006d35
Author: Matthias Metzger <[email protected]>
Authored: Fri Jul 15 20:01:45 2016 +0200
Committer: Matthias Metzger <[email protected]>
Committed: Fri Jul 15 20:26:08 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/wicket/model/IModel.java   | 11 ++++++-----
 .../java/org/apache/wicket/model/IModelTest.java    | 16 ++++++++--------
 2 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/a0c43bb9/wicket-core/src/main/java/org/apache/wicket/model/IModel.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/model/IModel.java 
b/wicket-core/src/main/java/org/apache/wicket/model/IModel.java
index 9fdac84..99c13ca 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/IModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/IModel.java
@@ -113,7 +113,8 @@ public interface IModel<T> extends IDetachable
        }
 
        /**
-        * Returns a IModel applying the given mapper to the contained object, 
if it is not {@code null}.
+        * Returns a IModel applying the given mapper to the contained object, 
if it is not {@code null}
+        * .
         *
         * @param <R>
         *            the new type of the contained object
@@ -145,14 +146,14 @@ public interface IModel<T> extends IDetachable
         *            the resulting type
         * @param <U>
         *            the other models type
-        * @param combiner
-        *            a function combining this and the others object to a 
result.
         * @param other
         *            another model to be combined with this one
+        * @param combiner
+        *            a function combining this and the others object to a 
result.
         * @return a new IModel
         */
-       default <R, U> IModel<R> mapWith(WicketBiFunction<? super T, ? super U, 
R> combiner,
-               IModel<U> other)
+       default <R, U> IModel<R> combineWith(IModel<U> other,
+               WicketBiFunction<? super T, ? super U, R> combiner)
        {
                Args.notNull(combiner, "combiner");
                Args.notNull(other, "other");

http://git-wip-us.apache.org/repos/asf/wicket/blob/a0c43bb9/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java 
b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
index acf10bd..965eac5 100644
--- a/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/model/IModelTest.java
@@ -93,41 +93,41 @@ public class IModelTest extends Assert
        }
 
        @Test
-       public void withMap()
+       public void combineWith()
        {
                IModel<String> janeModel = Model.of("Jane");
                WicketBiFunction<Person, String, String> function =
                                (WicketBiFunction<Person, String, String>) 
(person1, other) ->
                                                person1.getName() + " is in 
relationship with " + other;
-               IModel<String> relationShipModel = 
Model.of(person).mapWith(function, janeModel);
+               IModel<String> relationShipModel = 
Model.of(person).combineWith(janeModel, function);
                assertThat(relationShipModel.getObject(), is(equalTo("John is 
in relationship with Jane")));
        }
 
        @Test
-       public void withMapWithNullObject()
+       public void combineWithNullObject()
        {
                IModel<String> janeModel = Model.of((String)null);
                WicketBiFunction<Person, String, String> function =
                                (WicketBiFunction<Person, String, String>) 
(person1, other) ->
                                                person1.getName() + " is in 
relationship with " + other;
-               IModel<String> relationShipModel = 
Model.of(person).mapWith(function, janeModel);
+               IModel<String> relationShipModel = 
Model.of(person).combineWith(janeModel, function);
                assertThat(relationShipModel.getObject(), is(nullValue()));
        }
 
        @Test(expected = IllegalArgumentException.class)
-       public void withMapWithNullModel()
+       public void combineWithNullModel()
        {
                IModel<String> janeModel = null;
                WicketBiFunction<Person, String, String> function =
                                (WicketBiFunction<Person, String, String>) 
(person1, other) ->
                                                person1.getName() + " is in 
relationship with " + other;
-               Model.of(person).mapWith(function, janeModel);
+               Model.of(person).combineWith(janeModel, function);
        }
 
        @Test(expected = IllegalArgumentException.class)
-       public void withMapWithNullCombiner()
+       public void combineWithNullCombiner()
        {
-               Model.of(person).mapWith(null, Model.of("Jane"));
+               Model.of(person).combineWith(Model.of("Jane"), null);
        }
 
        @Test

Reply via email to