如何在嵌套列表中查找特定对象?

时间:2013-10-30 14:06:08

标签: java guava

在nestet列表中找到对象有什么好的可能吗?也许来自番石榴的东西支持以下内容:

class PriceInfo() {
    List<PriceType> types;
}

class PriceType() {
    String value;
}

List<PriceInfo> infos;

我如何执行:SELECT * from infos S WHERE S.types.value := 'TEST'? 甚至可以在更多嵌套列表中找到元素。

1 个答案:

答案 0 :(得分:4)

嵌套循环(我删除了我的评论,因为你需要嵌套循环):

for(PriceInfo info : infos){
 for(PriceType type : info.types) {
  if(type.value.equals("test") { }
 }
}

你可能会在外部库中获得一些异国情调的语法糖,但最终他们总会诉诸于每个项目。