title: Groovy printing Map<String,List<Map<String,String>>> data
body: <p>I have <code>Map&lt;String,List&lt;Map&lt;String,String&gt;&gt;&gt; invoices</code> as below</p>
  
  <pre><code>invLineItems = [INV-Error_Test1:[[LINE:1, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test1, INVOICE_TOTAL:22], [LINE:2, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test1, INVOICE_TOTAL:24]], 
              INV-Error_Test2:[[LINE:3, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test2, INVOICE_TOTAL:26], [LINE:4, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test2, INVOICE_TOTAL:28,]]]
  </code></pre>
  
  <p>I am trying to print it as below</p>
  
  <pre><code>println " INV-Error_Test2 Details "
  invLineItems.get('INV-Error_Test2').each{ 
      it.each{
  print "LINE = "+ it['LINE'] 
      }
   }
  </code></pre>
  
  <p>And am getting below error <code>groovy.lang.MissingPropertyException: No such property: LINE for class: java.util.LinkedHashMap$Entry</code></p>
  
  <p>Could someone help me with printing this data?</p>
  
  <p>NOTE: I actually have a total of 24 headers but to make the question simple i just posted 4 headers(<code>Line, Invoice_Date,Invoice-Number,Invoice_Total</code>) and am trying to print only few headers out of 24</p>
  
  <p>UPDATE: Am trying to update the <code>Map&lt;String,List&lt;Map&lt;String,String&gt;&gt;&gt; invoices</code> with the invoiceErrors as below</p>
  
  <pre><code>InvoiceError // is an entity with below attributes
  { String errorMessage,
    String invoiceNumber    
  }
  ErrorMessage                                          invoiceNumber   
  -------------                                       -------------------     
  File Error : The file is in an unsupported format   INV-Error_Test1
  Line : 1 Invoice does not foot Reported             INV-Error_Test1
  Line : 2 MATH ERROR                                 INV-Error_Test1
  Line : 3 MATH ERROR                                 INV-Error_Test2
  Line : 3 Invoice does not foot Reported             INV-Error_Test2
  </code></pre>
  
  <p>Am trying to achieve below map 
      If the error message doesnt have a line number it need to be appended at the top level as <code>invLineItems.put('error',['INV-Error_Test1' :</code>File Error : The file is in an unsupported format<code>])</code>
     Otherwise errormessage should be appended to the  matching INVOICE and linenumber as below</p>
  
  <pre><code>invLineItems = [INV-Error_Test1:[[LINE:1, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test1, INVOICE_TOTAL:22, error : `Line : 1 Invoice does not foot Reported`], 
                                  [LINE:2, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test1, INVOICE_TOTAL:24, error : `Line : 2 MATH ERROR`],
                  INV-Error_Test2:[[LINE:3, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test2, INVOICE_TOTAL:26, , error : `Line : 3 MATH ERROR | Line : 3 Invoice does not foot Reported`], 
                                  [LINE:4, INVOICE_DATE:20150301, INVOICE_NUMBER:INV-Error_Test2, INVOICE_TOTAL:28,]],
                  error : [[INV-Error_Test1:`File Error : The file is in an unsupported format`]]
  </code></pre>
  
  <p>I wrote the below method to achieve the above</p>
  
  <pre><code>def regex = "^Line\\s(?:(\\d+)\\s)?\\s*:\\s+(\\d+)?.+";
  for (e in invLineItems ){
    def errors =  lipErrors.findAll{it.invoiceNumber==e.key} // finding the error messages with the invoice number
    errors.each{  // fetching the line numbre from error message and finding the matching record the invoice number and line number in invLineItems 
       int lineNumber
       if (it.errorMessage.matches(regex)) {
              Pattern p = Pattern.compile("\\d+");
              Matcher m = p.matcher(it.errorMessage);
              if (m.find()) {
                   lineNumber = Integer.parseInt(m.group());
              }
            println "lineNumber = "+lineNumber
          }
  
      if(e.value['LINE_ITEM_NUMBER'].find{it==lineNumber.toString()}) {
        def data = lipErrors.findAll{it.invoiceNumber==e.key &amp;&amp; it.errorMessage.matches("^Line\\s+"+lineNumber+"?\\:\\s+"+lineNumber+"?.+")}
        e.getValue().each{it.put("error", data.errorMessage.join("|"))}
  
       }   
  
    }
  }   
  </code></pre>
  
  <p>The code doesnt look like Groovy and using traditional java code mostly, am wondering whether the code can be simplified with Groovy approach</p>