title: How to transform a If Construct in Java to a Switch Case with Strings or Enum Values?
body: <p>I have a xml document, that is saved as a string in the variable xmlRequest. I want to check, if a specific xml element is available in this xml document. I have a solution like this, but this a bad solution I would think:</p>
  
  <pre><code>if (xmlRequest.contains("&lt;Initial&gt;") &amp;&amp; xmlRequestBody.contains("&lt;/Initial&gt;")) {
     // do something specific for &lt;Initial&gt; 
  }
  if (xmlRequest.contains("&lt;Area&gt;") &amp;&amp; xmlRequestBody.contains("&lt;/Area&gt;")) {
     // do something for &lt;Area&gt;
  }
  if (xmlRequest.contains("&lt;Circle&gt;") &amp;&amp; xmlRequestBody.contains("&lt;/Circle&gt;")) {
     // do something for &lt;Circle&gt;
  }
  </code></pre>
  
  <p>An If Else construction is bad too, since the number of if cases can be grow up very high. I Think a switch case is the best way to solve this problem, but how can i build it, since a use boolean comparisons too.</p>