I defined a generic interface called IReportthat accepts a generic parameter typeT
public interface IReport<T> {
public enum ReportType {
YEARLY, MONTHLY, WEEKLY
}
public String getName();
public ReportType getType();
public Map<T, List<Cost>> getResults();
}
The class implements this interface.
public class WeeklyReport implements IReport<Days> {
public enum Days {
MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY
}
@Override
public String getName() {
return "Weekly report ";
}
@Override
public ReportType getType() {
return ReportType.WEEKLY;
}
@Override
public Map<Days, List<Cost>> getResults() {
return null;
}
}
If you see this, in WeeklyReport, Tis replaced by the type of enumeration, which is defined in the class itself WeeklyReport, which is equal Days. For this, eclipse gives a compiler error saying
Days cannot be allowed for type

If I use any other enumeration for general substitution (which is defined outside this class), then the compiler error disappears. Please help me with this problem.
source
share