Skip to content

Instantly share code, notes, and snippets.

@gregw
Created October 14, 2019 07:28
Show Gist options
  • Save gregw/707fe300cc02b780cef9d10154780c89 to your computer and use it in GitHub Desktop.
Save gregw/707fe300cc02b780cef9d10154780c89 to your computer and use it in GitHub Desktop.
private static boolean combine(IncludeExcludeSet<Entry, String> names, String name, IncludeExcludeSet<Entry, URI> locations, Supplier<URI> location)
{
// check the name set
Boolean byName = names.isIncludedAndNotExcluded(name);
// If we excluded by name, then no match
if (Boolean.FALSE == byName)
return false;
// check the location set
URI uri = location.get();
Boolean byLocation = uri == null ? null : locations.isIncludedAndNotExcluded(uri);
// If we excluded by location or couldn't check location exclusion, then no match
if (Boolean.FALSE == byLocation || (locations.hasExcludes() && uri == null))
return false;
// If there are includes, then we must be included to match.
if (names.hasIncludes() || locations.hasIncludes())
return byName == Boolean.TRUE || byLocation == Boolean.TRUE;
// Otherwise there are no includes and it was not excluded, so match
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment