Uploaded image for project: 'Causeway'
  1. Causeway
  2. CAUSEWAY-1213

Provide support for @Mixin domain objects, as a specialized type of contributor (though not a domain service)

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 1.9.0
    • 1.10.0
    • Core
    • None

    Description

      For example, rather than a contributed action:

      @DomainService(
              nature = NatureOfService.VIEW_CONTRIBUTIONS_ONLY
      )
      public class CommunicationChannel_updateNotes {
          @Action(
                  semantics = SemanticsOf.IDEMPOTENT
          )
          public <T extends CommunicationChannel<T>> CommunicationChannel<T> updateNotes(
                  CommunicationChannel<T> communicationChannel,
                  @Parameter(optionality = Optionality.OPTIONAL)
                  @ParameterLayout(named = "Notes", multiLine = 10)
                  final String Notes) {
              communicationChannel.setNotes(Notes);
              return communicationChannel;
          }
          public <T extends CommunicationChannel<T>> String default1UpdateNotes(
                  CommunicationChannel<T> communicationChannel
                  ) {
              return communicationChannel.getNotes();
          }
      }
      

      which requires passing in the contributee to every method, and ensuring that all methods are named correctly, we can instead say:

      @DomainObject(
              nature = Nature.MIXIN
      )
      public class CommunicationChannel_updateNotes {
          private final CommunicationChannel communicationChannel;
          public CommunicationChannel_updateNotes(CommunicationChannel communicationChannel) {
              this.communicationChannel = communicationChannel;
          }
         @Action(
                  domainEvent = UpdateNotesEvent.class,
                  semantics = SemanticsOf.IDEMPOTENT
          )
          public <T extends CommunicationChannel<T>> CommunicationChannel<T> __(
                  @Parameter(optionality = Optionality.OPTIONAL)
                  @ParameterLayout(named = "Notes", multiLine = 10)
                  final String Notes) {
              communicationChannel.setNotes(Notes);
              return communicationChannel;
          }
          public <T extends CommunicationChannel<T>> String default0__() {
              return communicationChannel.getNotes();
          }
      }
      

      where the name of the action is "_" meaning instead infer the action name from the name of the mixin class, and where the mixin has a constructor of the object being mixed in.

      Attachments

        Activity

          People

            Unassigned Unassigned
            danhaywood Daniel Keir Haywood
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: