【发布时间】:2016-05-11 17:30:37
【问题描述】:
我想在我的项目 Lightweight-Stream-API 和 RetroLambda 上使用流 api
代码:
Map<String, Object> liste = new HashMap<>();
for (Map.Entry<String, ?> data : tumListe.entrySet()) {
try{
if (data.getValue() != null) {
if(data.getValue() instanceof String){
try {
liste.put(data.getKey(), new Gson().fromJson(((String) data.getValue()), new TypeToken<List<String>>(){}.getType()));
}catch (JsonIOException ignored){
continue;
}catch (JsonParseException ignored){
continue;
}
}
liste.put(data.getKey(), data.getValue());
}
} catch (NullPointerException | ClassCastException ignored) {}
}
如何重构此代码以使用流,例如Stream.of()方法?
【问题讨论】:
标签: android hashmap java-stream