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

Generated DataObject interfaces should override DataObject.getImplementedClass()

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Duplicate
    • Icon: Medium Medium
    • None
    • None
    • Binding codegen
    • None

      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;
      }

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

              Created:
              Updated:
              Resolved: