Uploaded image for project: 'mdsal'
  1. mdsal
  2. MDSAL-470

Add DataObject default methods

XMLWordPrintable

      Generated DTOs capture their Object-related mechanics in two places:

      1. compile-time Builder implementations
      2. runtime codec bridge implementations

      Both of these should be indiscernible by the user, but there are subtle differences between them. It would be nice if we could eliminate those differences.

      A way to do that is to generate defaultToString() methods, like this:

      interface Foo extends DataObject {
          Bar getBar();
      
          static String bindingToString(final Foo obj) {
              return "Foo [bar = " + obj.getBar() + "]";
          }
      }
      

      Generated builders, as well as generated bridges can then do a simple:

      @Override
      public String toString() {
          return defaultToString(this);
      }
      

      which will result in the implementation being shared. This applies to hashCode()/equals() as well.

            ilyaigushev Ilya Igushev
            rovarga Robert Varga
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: