Uploaded image for project: 'Magnolia'
  1. Magnolia
  2. MAGNOLIA-5054

Generic return type of AutoGenerationConfiguration.getGeneratorClass() does not allow custom implementations

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Neutral
    • 4.5.x
    • 4.5.8
    • rendering

    Description

      The return type is:

      Class<Generator<AutoGenerationConfiguration>> getGeneratorClass();
      

      Which means that it has to be this exact class, or interface as it is in this case. That's obviously not what we want. We want it to be a class that implements the Generator interface with a custom configuration class as its type parameter.

      It should be:

      Class<? extends Generator<? extends AutoGenerationConfiguration>> getGeneratorClass();
      

      Here's an example of the problem:

          public static class MyAutoGenerationConfiguration implements AutoGenerationConfiguration {
      
              @Override
              public Map<String, Object> getContent() {
                  return null;
              }
      
              @Override
              public Class<Generator<AutoGenerationConfiguration>> getGeneratorClass() {
                  return MyGenerator.class; // DOES NOT COMPILE
              }
          }
      
          public static class MyGenerator implements Generator<AutoGenerationConfiguration> {
      
              @Override
              public void generate(AutoGenerationConfiguration configuration) throws RenderException {
              }
          }
      

      As a workaround one can cast to Class but it shouldn't be necessary.

              @Override
              public Class<Generator<AutoGenerationConfiguration>> getGeneratorClass() {
                  return (Class)MyGenerator.class; // COMPILES WITH WARNING
              }
      

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              tmattsson Tobias Mattsson
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Checklists

                  Bug DoR
                  Task DoD