The current version can run, but it must be poorly written.
List<? extends WeatherData> data = weatherReportDao.getCoviReportData(reportType);
WeatherENUM weatherENUM = WeatherENUM.valueOf(reportFunction);
switch (weatherENUM){
case atmosphere:
data = atmosphereReportDao.getAtmosphereReportData(reportType);
break;
case covi:
data = weatherReportDao.getCoviReportData(reportType);
break;
case windSpeed:
data = windSpeedReportDao.getWindSpeedReportData(reportType);
break;
}
return data;
The key is the initialization of data. If not initialized, an error will be reported. Ask for guidance.
習慣沉默2017-05-17 10:10:39
List<? extends WeatherData> data = null;
Or find a way to pass a certain value of weatherENUM as a parameter to dao
List<? extends WeatherData> data = weatherReportDao.getReportData(reportType,dataType);
phpcn_u15822017-05-17 10:10:39
If defined as a global variable, there is no need to initialize it.