You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2021/06/19 05:01:27 UTC

[isis] branch ISIS-2753 created (now 9ed31cf)

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a change to branch ISIS-2753
in repository https://gitbox.apache.org/repos/asf/isis.git.


      at 9ed31cf  ISIS-2753: changes AbstractDomainEvent#getSubject() to return <T> T

This branch includes the following new commits:

     new 9ed31cf  ISIS-2753: changes AbstractDomainEvent#getSubject() to return <T> T

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[isis] 01/01: ISIS-2753: changes AbstractDomainEvent#getSubject() to return T

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-2753
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 9ed31cfb9f8905b42c43d2a5fd55f0117c8c24e4
Author: danhaywood <da...@haywood-associates.co.uk>
AuthorDate: Sat Jun 19 06:00:50 2021 +0100

    ISIS-2753: changes AbstractDomainEvent#getSubject() to return <T> T
    
    so can remove boilerplate casting in the app
---
 .../apache/isis/applib/events/domain/AbstractDomainEvent.java    | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/api/applib/src/main/java/org/apache/isis/applib/events/domain/AbstractDomainEvent.java b/api/applib/src/main/java/org/apache/isis/applib/events/domain/AbstractDomainEvent.java
index 2bfa27e..da37c89 100644
--- a/api/applib/src/main/java/org/apache/isis/applib/events/domain/AbstractDomainEvent.java
+++ b/api/applib/src/main/java/org/apache/isis/applib/events/domain/AbstractDomainEvent.java
@@ -28,9 +28,11 @@ import org.apache.isis.applib.events.EventObjectBase;
 import org.apache.isis.applib.services.i18n.TranslatableString;
 import org.apache.isis.applib.util.ObjectContracts;
 import org.apache.isis.applib.util.ToString;
+import org.apache.isis.commons.internal.base._Casts;
 import org.apache.isis.commons.internal.exceptions._Exceptions;
 
 import lombok.Getter;
+import lombok.val;
 
 /**
  * Superclass for all domain events that are raised by the framework when
@@ -117,9 +119,10 @@ public abstract class AbstractDomainEvent<S> extends EventObjectBase<S> {
      * {@link #getSource() source} for a regular action, or the
      * {@link #getMixedIn() mixed-in} domain object for a mixin.
      */
-    public Object getSubject() {
-        final Object mixedIn = getMixedIn();
-        return mixedIn != null ? mixedIn : getSource();
+    public <T> T getSubject() {
+        val mixedIn = getMixedIn();
+        val mixedInElseSource = mixedIn != null ? mixedIn : getSource();
+        return _Casts.uncheckedCast(mixedInElseSource);
     }
 
     /**