[MAGNOLIA-5054] Generic return type of AutoGenerationConfiguration.getGeneratorClass() does not allow custom implementations Created: 23/May/13 Updated: 10/Mar/21 Resolved: 10/Mar/21 |
|
| Status: | Closed |
| Project: | Magnolia |
| Component/s: | rendering |
| Affects Version/s: | 4.5.8 |
| Fix Version/s: | 4.5.x |
| Type: | Bug | Priority: | Neutral |
| Reporter: | Tobias Mattsson | Assignee: | Unassigned |
| Resolution: | Won't Do | Votes: | 0 |
| Labels: | next | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Bug DoR: |
[ ]*
Steps to reproduce, expected, and actual results filled
[ ]*
Affected version filled
|
| 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
}
|