title: What is the optimal way to check if a map contains any empty values or keys?
body: <p>I have a map that stores a set of questions and answers. There cannot be questions with empty answers or answers with empty questions. Below is how I have initialized my map.</p>
  <pre><code>Optional&lt;Map&lt;String, String&gt;&gt; questionsAndAnswers();
  </code></pre>
  <p>I'm validating the empty strings for questions/answers in the following manner.</p>
  <pre><code>questionsAndAnswers().ifPresent(questionsAndAnswers -&gt; {
          if (questionsAndAnswers.isEmpty()) {
              throw new IllegalArgumentException(&quot;questions cannot be empty if present&quot;);
          } else if (questionsAndAnswers.keySet().contains(&quot;&quot;) || questionsAndAnswers.values().contains(&quot;&quot;)) {
              throw new IllegalArgumentException(&quot;Questions or answers cannot be empty&quot;);
          }
      });
  </code></pre>
  <p>Is there a better way to achieve this? Any advice would be much appreciated.</p>
  <p>UPDATE: There's no specific need for me to have these checks done in two separate conditions.</p>