例如,我从服务门户创建了“事件”列表:
List<Incident> incidentObjectList = new ArrayList<>();
for (int i = 0; i < incidentNumberList.size(); i++) {
Incident incident = new Incident();
incident.setIncidentNumber(incidentNumberList.get(i));
incident.setSummary(summaryList.get(i));
incident.setRequestId(requestIdList.get(i));
incident.setPriority(priorityList.get(i));
incident.setLastModifiedDate(lastModifiedDateList.get(i));
incidentObjectList.add(incident);
}
System.out.println("Incident Object List" + incidentObjectList);
每个事件都有几个属性,但是我只想从由优先级为
Low
的事件对象组成的原始列表创建一个新列表。在这种情况下,incident.getPriority()
将为新列表中的所有对象返回字符串Low
。String[] dataGreenArray = incidentObjectList.get();
retrieveTickets(dataGreenArray, listViewGreen);
最佳答案
遍历incidentObjectList
并检查每个元素的优先级。
for (Incident incident: incidentObjectList)
{
if (incident.getPriority().equals("Low")
desiredList.add(incident); // or whatever you want to do
}
这是一个非常基本的解决方案,但是除非您正在专门寻找其他东西,否则它应该可以工作。希望能帮助到你!