Source:
@Override public boolean matchesSource(@Nonnull Origin origin, @Nonnull URI resource) { if (origin instanceof GUID) { return this.isWildcard() && resource.isNetworkScheme(); } else if (!(origin instanceof SchemeHostPortTriple)) { return false; } SchemeHostPortTriple shpOrigin = (SchemeHostPortTriple) origin; if (this.isWildcard()) { return resource.isNetworkScheme() || shpOrigin.scheme.matches(resource.scheme); } boolean schemeMatches; if (this.scheme == null) { schemeMatches = resource.isNetworkScheme() ? shpOrigin.isNetworkScheme() : resource.scheme.equalsIgnoreCase(shpOrigin.scheme); } else { if (resource.isNetworkScheme() && !resource.scheme.equalsIgnoreCase("ftp") && !this.scheme.equalsIgnoreCase("ftp")) { schemeMatches = resource.isSecureScheme() ? SchemeHostPortTriple.isSchemeNetworkScheme(this.scheme) : !SchemeHostPortTriple.isSchemeSecureScheme(this.scheme); } else { schemeMatches = this.scheme.equalsIgnoreCase(resource.scheme); } } boolean hostMatches = this.host.equals("*") || (this.host.startsWith("*.") ? resource.host.toLowerCase().endsWith(this.host.substring(1).toLowerCase()) : this.host.equalsIgnoreCase(resource.host)); boolean uriUsesDefaultPort = resource.port == Constants.EMPTY_PORT || SchemeHostPortTriple.defaultPortForProtocol(resource.scheme) == resource.port; boolean thisUsesDefaultPort = this.scheme != null && (this.port == Constants.EMPTY_PORT || SchemeHostPortTriple.defaultPortForProtocol(this.scheme) == this.port); boolean portMatches = this.port == Constants.WILDCARD_PORT || (thisUsesDefaultPort && uriUsesDefaultPort) || (this.port == Constants.EMPTY_PORT ? uriUsesDefaultPort : (resource.port == Constants.EMPTY_PORT ? thisUsesDefaultPort : this.port == resource.port)); boolean pathMatches = this.path == null || (this.path.endsWith("/") ? resource.path.startsWith(this.path) : this.path.equals(resource.path)); return schemeMatches && hostMatches && portMatches && pathMatches; }

Target:
@Override public boolean matchesSource(@Nonnull Origin origin, @Nonnull URI resource) { if (origin instanceof GUID) { return this.isWildcard() && resource.isNetworkScheme(); } else if (!(origin instanceof SchemeHostPortTriple)) { return false; } SchemeHostPortTriple shpOrigin = (SchemeHostPortTriple) origin; if (this.isWildcard()) { return resource.isNetworkScheme() || shpOrigin.scheme.matches(resource.scheme); } boolean schemeMatches; if (this.scheme == null) { schemeMatches = SchemeHostPortTriple.matchesSecureScheme(shpOrigin.scheme, resource.scheme); } else { schemeMatches = SchemeHostPortTriple.matchesSecureScheme(this.scheme, resource.scheme); } boolean hostMatches = this.host.equals("*") || (this.host.startsWith("*.") ? resource.host.toLowerCase().endsWith(this.host.substring(1).toLowerCase()) : this.host.equalsIgnoreCase(resource.host)); boolean uriUsesDefaultPort = resource.port == Constants.EMPTY_PORT || SchemeHostPortTriple.defaultPortForProtocol(resource.scheme) == resource.port; boolean thisUsesDefaultPort = this.scheme != null && (this.port == Constants.EMPTY_PORT || SchemeHostPortTriple.defaultPortForProtocol(this.scheme) == this.port); boolean portMatches = this.port == Constants.WILDCARD_PORT || (thisUsesDefaultPort && uriUsesDefaultPort) || (this.port == Constants.EMPTY_PORT ? uriUsesDefaultPort : (resource.port == Constants.EMPTY_PORT ? thisUsesDefaultPort : this.port == resource.port)); boolean pathMatches = this.path == null || (this.path.endsWith("/") ? resource.path.startsWith(this.path) : this.path.equals(resource.path)); return schemeMatches && hostMatches && portMatches && pathMatches; }