meteoinfo / MeteoInfo

MeteoInfo: GIS, scientific computation and visualization environment.
http://www.meteothink.org/
GNU Lesser General Public License v3.0
317 stars 94 forks source link

Views.java 类中出现List<String>,List<Object>类型不匹配错误 #7

Closed Anyuei closed 5 years ago

Anyuei commented 5 years ago

MeteoInfo-master\MeteoInfoLib\src\main\java\org\meteoinfo\data\dataframe\impl\Views.java 类中 entrySet中的迭代器iterator类型不匹配。 尝试用以下方法解决: 添加转换方法: public static <T> List<T> castList(Object obj, Class<T> clazz) { List<T> result = new ArrayList<T>(); if(obj instanceof List<?>) { for (Object o : (List<?>) obj) { result.add(clazz.cast(o)); } return result; } return null; } 使用转换方法: final List names = transpose ? df.getIndex().getValues() : castList(df.getColumns().getNames(), Object.class);

Yaqiang commented 5 years ago

Change to:

final List names = transpose ? df.getIndex().getValues() : new ArrayList<>(df.getColumns().getNames());

Anyuei commented 5 years ago

That's OK