list - java code optimization
PHP中文网
PHP中文网 2017-05-17 10:08:39
0
2
644

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.

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
習慣沉默
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_u1582

If defined as a global variable, there is no need to initialize it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template