You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2017/07/18 19:46:52 UTC

wicket git commit: WICKET-6412 Model#orElse behavior is inconsistent!

Repository: wicket
Updated Branches:
  refs/heads/master 42bf89653 -> 3e6aa9b9f


WICKET-6412 Model#orElse behavior is inconsistent!

Add javadoc to IModel#orElse() with possible usages.


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

Branch: refs/heads/master
Commit: 3e6aa9b9f8ae447a2f99e6192aebe45b05761a8f
Parents: 42bf896
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Tue Jul 18 21:29:34 2017 +0200
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Tue Jul 18 21:29:34 2017 +0200

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/model/IModel.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/3e6aa9b9/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 f34645e..d33d061 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
@@ -276,6 +276,18 @@ public interface IModel<T> extends IDetachable
 	 * Returns a IModel, returning either the contained object or the given default value, depending
 	 * on the {@code null}ness of the contained object.
 	 *
+	 * <p>
+	 * Possible usages:
+	 * <ul>
+	 *     <li>{@code myComponent = new AnyComponent(&quot;someId&quot;, someModel.orElse(defaultValue));}
+	 *      - This way Wicket will make use of the default value if the model object of <em>someModel</em>
+	 *      is {@code null}.
+	 *     </li>
+	 *     <li>in the middle of the application logic: {@code ... = someModel.orElse(default).getModelObject();}</li>
+	 * </ul>
+	 *
+	 * </p>
+	 *
 	 * @param other
 	 *            a default value
 	 * @return a new IModel