This is an automated email from the ASF dual-hosted git repository. adelbene pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/wicket.git
commit 5b54fda399cf5e38c7ee745e1016d8ef363b44b2 Author: Andreas Svanberg <andreas.svanb...@mensa.se> AuthorDate: Fri Oct 20 10:46:42 2023 +0200 Rename poly to as --- .../src/test/java/org/apache/wicket/model/IModelTest.java | 12 ++++++------ .../src/main/java/org/apache/wicket/model/IModel.java | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/wicket-core-tests/src/test/java/org/apache/wicket/model/IModelTest.java b/wicket-core-tests/src/test/java/org/apache/wicket/model/IModelTest.java index 09d1a1dc40..741c17d639 100644 --- a/wicket-core-tests/src/test/java/org/apache/wicket/model/IModelTest.java +++ b/wicket-core-tests/src/test/java/org/apache/wicket/model/IModelTest.java @@ -244,31 +244,31 @@ class IModelTest } @Test - void polymorphicModelWrongClass() + void asModelWrongClass() { IModel<TextMatchingStatus> statusModel = LoadableDetachableModel.of(() -> new TextMatchingStatus.Error(3, "File too big")); - IModel<TextMatchingStatus.Queued> poly = statusModel.poly(TextMatchingStatus.Queued.class); + IModel<TextMatchingStatus.Queued> poly = statusModel.as(TextMatchingStatus.Queued.class); assertNull(poly.getObject()); } @Test - void polymorphicModelCorrectClass() + void asModelCorrectClass() { IModel<TextMatchingStatus> statusModel = LoadableDetachableModel.of(() -> new TextMatchingStatus.Analysed(14)); - IModel<TextMatchingStatus.Analysed> poly = statusModel.poly(TextMatchingStatus.Analysed.class); + IModel<TextMatchingStatus.Analysed> poly = statusModel.as(TextMatchingStatus.Analysed.class); assertNotNull(poly.getObject()); assertEquals(new TextMatchingStatus.Analysed(14), poly.getObject()); } @Test - void nullPoly() + void nullAs() { assertThrows(IllegalArgumentException.class, () -> { - LoadableDetachableModel.of(TextMatchingStatus.NotSubmitted::new).poly(null); + LoadableDetachableModel.of(TextMatchingStatus.NotSubmitted::new).as(null); }); } 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 e9799682ea..c58e7448b1 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 @@ -378,7 +378,7 @@ public interface IModel<T> extends IDetachable * @param clazz the {@code Class} the current model object should be an instance of * @return a new IModel */ - default <R extends T> IModel<R> poly(Class<R> clazz) { + default <R extends T> IModel<R> as(Class<R> clazz) { Args.notNull(clazz, "clazz"); return filter(clazz::isInstance).map(clazz::cast); }