Remove Repeated Code
<p>My Question is-</p>

<p>I have two string variables <code>site_inclusion</code> and <code>site_exclusion</code>.  If <code>site_inclusion</code> has a value, then I don't care what values <code>site_exclusion</code> contains.  That is to say that <code>site_inclusion</code> overrides <code>site_exclusion</code>.  If, however,  <code>site_inclusion</code> is <code>null</code> and <code>site_exclusion</code> has a value, then I want to examine <code>site_exclusion</code>.</p>

<p>To be more precise:</p>

<ol>
<li>If <code>site_inclusion</code> and <code>site_exclusion</code> are both <code>null</code> then set <code>useTheSynthesizer</code> as <code>true</code>;</li>
<li>If <code>site_inclusion</code> is not <code>null</code> and it matches with the <code>regexPattern</code> then set <code>useTheSynthesizer</code> as <code>true</code>.  And I don't care what values are there in <code>site_exclusion</code>.</li>
<li>If <code>site_inclusion</code> is <code>null</code> and <code>site_exclusion</code> is not <code>null</code> and <code>site_exclusion</code> does not match the <code>regexPattern</code> then set <code>useTheSynthesizer</code> to true.</li>
</ol>

<p>I wrote the below code but somehow I think, <strong>I am repeating some stuff here</strong> in the if/else loop. Any code improvements will be appreciated that fulfill my conditions.</p>

<pre><code>String site_inclusion = metadata.getSiteInclusion();
String site_exclusion = metadata.getSiteExclusion();

// fix for redundant data per site issue
if(site_inclusion != null &amp;&amp; site_inclusion.matches(regexPattern)) {
    useTheSynthesizer = true;
} else if(site_exclusion != null &amp;&amp; !(site_exclusion.matches(regexPattern))) {
    useTheSynthesizer = true;
} else if(site_inclusion == null &amp;&amp; site_exclusion == null ) {
    useTheSynthesizer = true;
}
</code></pre>
