I have two string variables site_inclusion
and site_exclusion
. If site_inclusion
has some values, then I don't care what values site_exclusion
contains. This means site_inclusion
overrides site_exclusion
if site_inclusion
has some values. But if site_inclusion
is null and site_exclusion
has some values, then go into the site_exclusion
loop.
Requirements:
- If site_inclusion and site_exclusion both are null then set
useTheSynthesizer
as true; - If site_inclusion is not null and it matches with the
regexPattern
then setuseTheSynthesizer
as true. And I don't care what values are there in site_exclusion. - If
site_inclusion
is null andsite_exclusion
is not null andsite_exclusion
does not match the regexPattern, then setuseTheSynthesizer
to true.
I wrote the below code but somehow I think I am repeating some stuff here in the if/else loop. Any code improvements that fulfill my conditions will be appreciated.
String site_inclusion = metadata.getSiteInclusion();
String site_exclusion = metadata.getSiteExclusion();
// fix for redundant data per site issue
if(site_inclusion != null && site_inclusion.matches(regexPattern)) {
useTheSynthesizer = true;
} else if(site_exclusion != null && !(site_exclusion.matches(regexPattern))) {
useTheSynthesizer = true;
} else if(site_inclusion == null && site_exclusion == null ) {
useTheSynthesizer = true;
}