/*
@see org.osgi.service.url.URLStreamHandlerService#hostsEqual(java.net.URL, java.net.URL)
495648
@Override
    public boolean hostsEqual(URL url1, URL url2) {
        try {
            Boolean result = (Boolean) _hostsEqual.invoke(getInstance(),
                                                          new Object[] { url1, url2 });
            return result.booleanValue();
        } catch (Exception e) {
            FFDCFilter.processException(e, getClass().getName(), "hostsEqual", new Object[] { url1, url2 });
            return false;
        }
    }
378345
@SuppressWarnings("unchecked")
  public T compareRawLocation() {
    if (!this.result) {
      this.result |= (!new Path(this.existingUnit.getLocation().get()).toUri().getRawPath()
          .equals(new Path(this.newUnit.getLocation().get()).toUri().getRawPath()));
    }
    return (T) this;
  }
1106654
public static String getHostFromURL(String url) {
		URL u = toURL(url);
		String host = (u == null) ? "" : u.getHost();
		return host;
	}
1019456
public function equals(HostInterface $host): bool
    {
        if ($this->getIPAddress() !== null && $host->getIPAddress() !== null) {
            return $this->getIPAddress()->equals($host->getIPAddress());
        }

        return $this->getHostname()->equals($host->getHostname());
    }
338579
public boolean isEqualTo(String version) {
        JenkinsVersion create = create(version);
        return this.cv.compareTo(create.cv) == 0;
    }
1101574
static void ensureHostnamePatternMatchesDefaultHostname(String hostnamePattern, String defaultHostname) {
        if ("*".equals(hostnamePattern)) {
            return;
        }

        // Pretty convoluted way to validate but it's done only once and
        // we don't need to duplicate the pattern matching logic.
        final DomainNameMapping<Boolean> mapping =
                new DomainNameMappingBuilder<>(Boolean.FALSE).add(hostnamePattern, Boolean.TRUE).build();

        if (!mapping.map(defaultHostname)) {
            throw new IllegalArgumentException(
                    "defaultHostname: " + defaultHostname +
                    " (must be matched by hostnamePattern: " + hostnamePattern + ')');
        }
    }
616321
@Override
    public void setURI(URI uri) throws URIException {
        // only set the host if specified by the URI
        if (uri.isAbsoluteURI()) {
            this.httphost = new HttpHost(uri);
        }
        // set the path, defaulting to root
        setPath(
            uri.getPath() == null
            ? "/"
            : uri.getEscapedPath()
        );
        setQueryString(uri.getEscapedQuery());
    }
1240380
protected boolean hostsEqual(URL u1, URL u2) {
        /*
         * Special case for file: URLs
         * per RFC 1738 no hostname is equivalent to 'localhost'
         * i.e. file:///path is equal to file://localhost/path
         */
        String s1 = u1.getHost();
        String s2 = u2.getHost();
        if ("localhost".equalsIgnoreCase(s1) && ( s2 == null || "".equals(s2)))
            return true;
        if ("localhost".equalsIgnoreCase(s2) && ( s1 == null || "".equals(s1)))
            return true;
        return super.hostsEqual(u1, u2);
    }
843913
public static boolean isLocalHost(String host) {
        return StringUtils.isNotBlank(host)
            && (LOCAL_IP_PATTERN.matcher(host).matches() || "localhost".equalsIgnoreCase(host));
    }
707131
@Override
	public boolean apply(final URI uri) {
		String host = uri.getHost(); // BURL guarantees lower case.
		for (String suffix: suffixes) if (host.endsWith(suffix)) return true;
		return false;
	}
330519
public function equals(KHttpUrlInterface $url)
    {
        $parts = array('scheme', 'host', 'port', 'path', 'query', 'fragment');

        foreach($parts as $part)
        {
            if($this->{$part} != $url->{$part}) {
                return false;
            }
        }

        return true;
    }
771349
def _paths_equal(lhs, rhs):
    

    if lhs is rhs:
        return True
    if lhs.host is not None and rhs.host is not None and lhs.host != rhs.host:
        return False
    # need to make sure this stays in sync with CIMInstanceName.__cmp__()
    return not (pywbem.cmpname(rhs.classname, lhs.classname) or
                cmp(rhs.keybindings, lhs.keybindings) or
                pywbem.cmpname(rhs.namespace, lhs.namespace))
887409
private synchronized HostServerGroupEffect getHostEffect(PathAddress address, String host, Resource root)  {
        if (requiresMapping) {
            map(root);
            requiresMapping = false;
        }
        Set<String> mapped = hostsToGroups.get(host);
        if (mapped == null) {
            // Unassigned host. Treat like an unassigned profile or socket-binding-group;
            // i.e. available to all server group scoped roles.
            // Except -- WFLY-2085 -- the master HC is not open to all s-g-s-rs
            Resource hostResource = root.getChild(PathElement.pathElement(HOST, host));
            if (hostResource != null) {
                ModelNode dcModel = hostResource.getModel().get(DOMAIN_CONTROLLER);
                if (!dcModel.hasDefined(REMOTE)) {
                    mapped = Collections.emptySet(); // prevents returning HostServerGroupEffect.forUnassignedHost(address, host)
                }
            }
        }
        return mapped == null ? HostServerGroupEffect.forUnassignedHost(address, host)
                : HostServerGroupEffect.forMappedHost(address, mapped, host);

    }
1202431
@Override
    protected void generateEqualsMethod(ClassFile proxyClassType) {
        ClassMethod method = proxyClassType.addMethod(AccessFlag.PUBLIC, "equals", BytecodeUtils.BOOLEAN_CLASS_DESCRIPTOR, LJAVA_LANG_OBJECT);
        CodeAttribute b = method.getCodeAttribute();
        b.aload(1);
        b.instanceofInstruction(proxyClassType.getName());
        b.returnInstruction();
    }
10373
def paths_equal(self, lhs, rhs):
        

        if lhs is rhs:
            return True
        if lhs.host is not None and rhs.host is not None and\
           lhs.host != rhs.host:
            return False
        # need to make sure this stays in sync with CIMInstanceName.__cmp__()
        return not (pywbem.cmpname(rhs.classname, lhs.classname) or
                    cmp(rhs.keybindings, lhs.keybindings) or
                    pywbem.cmpname(rhs.namespace, lhs.namespace))
815818
@SuppressWarnings({ "PMD.CyclomaticComplexity", "PMD.NPathComplexity",
        "PMD.CollapsibleIfStatements", "PMD.DataflowAnomalyAnalysis" })
    public int matches(URI resource) {
        if (protocol != null && !protocol.equals("*")) {
            if (resource.getScheme() == null) {
                return -1;
            }
            if (Arrays.stream(protocol.split(","))
                .noneMatch(proto -> proto.equals(resource.getScheme()))) {
                return -1;
            }
        }
        if (host != null && !host.equals("*")) {
            if (resource.getHost() == null
                || !resource.getHost().equals(host)) {
                return -1;
            }
        }
        if (port != null && !port.equals("*")) {
            if (Integer.parseInt(port) != resource.getPort()) {
                return -1;
            }
        }

        String[] reqElements = PathSpliterator.stream(resource.getPath())
            .skip(1).toArray(size -> new String[size]);
        String[] reqElementsPlus = null; // Created lazily
        for (int pathIdx = 0; pathIdx < pathPatternElements.length; pathIdx++) {
            String[] pathPattern = pathPatternElements[pathIdx];
            if (prefixSegs[pathIdx] == pathPattern.length - 1
                && lastIsEmpty(pathPattern)) {
                // Special case, pattern ends with vertical bar
                if (reqElementsPlus == null) {
                    reqElementsPlus = reqElements;
                    if (!lastIsEmpty(reqElementsPlus)) {
                        reqElementsPlus = Arrays.copyOf(
                            reqElementsPlus, reqElementsPlus.length + 1);
                        reqElementsPlus[reqElementsPlus.length - 1] = "";
                    }
                }
                if (matchPath(pathPattern, reqElementsPlus)) {
                    return prefixSegs[pathIdx];
                }
            } else {
                if (matchPath(pathPattern, reqElements)) {
                    return prefixSegs[pathIdx];
                }
            }
        }
        return -1;
    }
1014869
def is_same_host(self, url):
        
        if url.startswith('/'):
            return True

        # TODO: Add optional support for socket.gethostbyname checking.
        scheme, host, port = get_host(url)

        host = _ipv6_host(host).lower()

        # Use explicit default port for comparison when none is given
        if self.port and not port:
            port = port_by_scheme.get(scheme)
        elif not self.port and port == port_by_scheme.get(scheme):
            port = None

        return (scheme, host, port) == (self.scheme, self.host, self.port)