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

Generated DataObject interfaces should override DataObject.getImplementedClass()

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Medium
    • Resolution: Duplicate
    • None
    • None
    • Binding codegen
    • None

    Description

      We currently purely inherit this class, which is suboptimal when dealing with generics, most notably this case does not work:

      interface Foo extends DataObject;
      
      public <T extends Foo> void doSomething(T foo) {
          Class<? extends T> fooSubclass = foo.getImplementedInterface();
      }
      

      While all implementations are already returning the right answer (and if they don't Binding just breaks down), it is not expressed in the interface contract.

      This this by generating a default interface method:

      interface Foo extends DataObject {
          @Override
          default Class<? extends Foo> getImplementedInterface() {
              return Foo.class;
          }
      }
      

      This already exists in Builder's implementation generator, albeit in the form:

      @Override
      public Class<Foo> getImplementedInterface() {
          return Foo.class;
      }

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: