2016-11-10 36 views
1

这里我想知道如果list.cust.getComponentIdentification()值包含相同的值,那么我想选择该值。查找列表是否包含相同的数据?

for(CustomizableMenus cust : ra.getAction().getCustomizablemenu()){ 

         cust.getComponentId(); 
         cust.getComponentIdentification(); 
         cust.getComponentName(); 
         cust.getComponentState(); 
         custList.add(cust); 
} 

如果用户有相同的componentIdentification那么我想找到各自的组件标识。

+0

贵国的英语isunclear。 2.你使用的是什么java库?你可能不应该循环。 – philipxy

+0

抱歉,我是英文周。我使用1.8,我的意图是我想找到如果列表包含cust.getComponentIdentification()值相同,那么我想找到它们。 – mike

+0

请:编辑你的英文更清晰。阅读[问]。举例输入和输出。给一个[mcve]。什么是您使用的任何软件的全名?您用来通过Java访问数据库的库的确切名称是什么? “1.8”不清楚。 PS在你的答案中编辑澄清。评论是短暂的;他们不是澄清。 – philipxy

回答

0

据我所知,你想找到列表中的东西是否与用户具有相同的东西。

假装有一个对象“用户”,你可以做这样的事情:

User user = new User(); 
for (CustomizableMenus cust : ra.getAction().getCustomizablemenu()){ 
    if (user.getComponentIdentification() == cust.getComponentIdentification()) { 
     // do whatever you need with it. 
     // you might also add a break here. 
    } 
} 

请让我知道,如果它不是你需要的到底是什么,所以我可以提高我的答案。

0

串流和使用过滤器:

List<CustomizableMenus> found = ra.getAction().getCustomizablemenu() 
    .stream() 
    .filter(cm -> cm.getComponentIdentification().equals(componentIdentification)) 
    .collect(Collectors.toList()); 
+0

如果这回答你的问题,让我知道,我会编辑你的问题,使其更清晰。 – Bohemian

相关问题