Java error - compiler - an enumeration defined in a class cannot be used for general substitution in the same class

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

enter image description here

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.

+3
source share
1 answer

, , WeeklyReport#getResults(), Map<Days, List<Cost>>, Days .

static, static. getResults(), :

public class WeeklyReports implements IReport<WeeklyReports.Days> {
    ..
    public Map<WeeklyReport.Days, List<Cost>> getResults() {
        ...
    }
    ..
}
+3

All Articles