我有以下列表和代碼從名單越來越沒有重複(Groovy中)
def myList = [[id:8100-04, name:AAA, code:2281],
[id:8100-05, name:BBB, code:2102],
[id:8100-06, name:CCC, code:6089],
[id:8100-07, name:CCC, code:6089],
[id:8100-08, name:CCC, code:6089]]
//list is retrived but looks something like the above
def newList = myList.findAll {
(it.get("Name").equals("AAA") ||
it.get("Name").equals("BBB") ||
it.get("Name").equals("AFBO") ||
it.get("Name").equals("CCC")) }
def filteredListData = newList.collect { getListData(it.get("Id"), it.get("Name"),
it.get("Code")) }
我想找回我的所有newList的,如果有重複的,然後檢索與最低ID索引的條目。
所以從myList中我期待的結果是:
[[id:8100-04, name:AAA, code:2281],
[id:8100-05, name:BBB, code:2102],
[id:8100-06, name:CCC, code:6089]]
JCK,希望複製應根據'名稱和code'來識別。請檢查答案。 – Rao