I have a invoiceList which is a List<Map<String:String>> and am trying to find out if all the invoices have same SENDER_COUNTRY and CLIENT_COUNTRY or not. If not, it will add the message to a JSON array.[    [INVOICE_DATE:20150617, INVOICE_NUMBER:617151,SENDER_COUNTRY:USA, CLIENT_COUNTRY:USA]    [INVOICE_DATE:20150617, INVOICE_NUMBER:617152,SENDER_COUNTRY:CAD, CLIENT_COUNTRY:MEX]    [INVOICE_DATE:20150617, INVOICE_NUMBER:617153,SENDER_COUNTRY:CAD, CLIENT_COUNTRY:MEX]]JSONArray jsonArray = new JSONArray();def senderCountry = invoiceList[0]['SENDER_COUNTRY']def clientCountry  = invoiceList[0]['CLIENT_COUNTRY']invoiceList.each{ it ->if(it['SENDER_COUNTRY'] != senderCountry)  jsonArray.add((new JSONObject()).put(SENDER_COUNTRY,Multiple sender Countries Associated)); if(it['CLIENT_COUNTRY'] != clientCountry)  jsonArray.add((new JSONObject()).put(CLIENT_COUNTRY,Multiple Client Countries Associated));}I feel this code can be refactored/optimized to a better version in Groovy. Can someone please help me with it?
Finding duplicate invoices
performance;groovy