title: How to only return true when all conditions in for loop are true?
body: <ul>
  <li>I have a keyStore, that can consist of one or many key value pairs</li>
  <li>I have a nodeMap that can consist of one or many key value pairs</li>
  <li>All keys in keyStore must exist in nodeMap and all key value pairs from keyStore must match in nodeMap to return true</li>
  </ul>
  
  <p>For example:</p>
  
  <pre><code>keyStore {key1=&gt;value1}
  nodeMap  {key1=&gt;value1, key2=&gt;value2}
  return true
  
  ----
  
  keyStore {key1=&gt;value1, key2=&gt;value2}
  nodeMap  {key1=&gt;value1, key2=&gt;value2}
  return true
  
  ----
  
  keyStore {key1=&gt;value1, key3=&gt;value3}
  nodeMap  {key1=&gt;value1, key2=&gt;value2}
  return false;
  
  ----
  
  keyStore {key1=&gt;value1, key3=&gt;value3}
  nodeMap  {key1=&gt;value1, key2=&gt;value2, key3=&gt;value3}
  return true;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>private boolean checkForMatch(NamedNodeMap nodeMap, Map&lt;String, String&gt; keyStore)
     {
        boolean foundMatch = false;
        for (int i = 0; i &lt; nodeMap.getLength(); i++)
        {
           Node node = nodeMap.item(i);
           String nodeName = node.getNodeName();
           if (keyStore.containsKey(nodeName))
           {
              if (keyStore.get(nodeName).contains(node.getNodeValue()))
              {
                 foundMatch = true;
              }
              else
              {
                 foundMatch = false;
                 break;
              }
           }
        }
        return foundMatch;
     }
  </code></pre>
  
  <p>This will not work for several reasons e.g, when nodeMap consists of many key value pairs but keyStore consists of only one key value pair, while first conditions fails then loop breaks, instead of continuing.</p>