InetAddress equals - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for InetAddress equals method.

This code example shows how to use the following methods:equals
        }); 
    } 
 
    public int compareEndpoints(InetAddress address, InetAddress a1, InetAddress a2)
    { 
        if (address.equals(a1) && !address.equals(a2))
            return -1; 
        if (address.equals(a2) && !address.equals(a1))
            return 1; 
 
        String addressRack = getRack(address);
        String a1Rack = getRack(a1);
        String a2Rack = getRack(a2);
        if (addressRack.equals(a1Rack) && !addressRack.equals(a2Rack))
            return -1; 
        if (addressRack.equals(a2Rack) && !addressRack.equals(a1Rack))
            return 1; 
 
        String addressDatacenter = getDatacenter(address);
        String a1Datacenter = getDatacenter(a1);

6
CodeRank
This code example shows how to use the following methods:equals, isLoopbackAddress
                    throw e;
                } 
            } 
            if (optID == SocketOptions.IP_MULTICAST_IF && (flags & MULTICAST_IF) != 0) {
                InetAddress inet = (InetAddress) val;
                if (NetUtil.bytesToInt(inet.getAddress(), 0) == 0 || inet.isLoopbackAddress()) {
                    ipaddress = ((InetAddress) val).getAddress();
                } else { 
                    InetAddress local = null;
                    try { 
                        local = InetAddress.getLocalHost();
                    } catch (UnknownHostException e) {
                        throw new SocketException("getLocalHost(): " + e.toString());
                    } 
                    if (inet.equals(local)) {
                        ipaddress = ((InetAddress) val).getAddress();
                    } else { 
                        throw new SocketException(val + " != getLocalHost(): " + local);
                    } 
                } 
5
CodeRank
This code example shows how to use the following methods:equals, toString
	@Override 
	public String toString() {
		StringBuilder b = new StringBuilder();
		String t = start.toString();
		b.append(t.substring(t.indexOf('/') + 1));
		if (!end.equals(start)) {
			b.append('-');
			t = end.toString();
			b.append(t.substring(t.indexOf('/') + 1));
		} 
		return b.toString();
	} 
} 
5
CodeRank
This code example shows how to use the following methods:equals
        return list;
    } 
 
    public void sortByProximity(final InetAddress address, List<InetAddress> addresses)
    { 
        assert address.equals(FBUtilities.getLocalAddress()); // we only know about ourself
        if (BADNESS_THRESHOLD == 0)
        { 
            sortByProximityWithScore(address, addresses);
        } 
        else 
        { 
            sortByProximityWithBadness(address, addresses);
        } 
    } 
 
    private void sortByProximityWithScore(final InetAddress address, List<InetAddress> addresses)
    { 
        Collections.sort(addresses, new Comparator<InetAddress>()
        { 
5
CodeRank
This code example shows how to use the following methods:equals
This code example shows how to use the following methods:equals
	@Override 
	public boolean equals(final Object other)
	{ 
		if (!(other instanceof Endpoint)) { return false; }
		final Endpoint ep = (Endpoint) other;
		return address.equals(ep.address) && port == ep.port && subport == ep.subport;
	} 
 
	protected SocketAddress getAddress()
	{ 
		return new InetSocketAddress(address, port);
	} 
 
	/** 
	 * Get the <code>Subport</code> value. 
	 *  
	 * @return an <code>int</code> value 
	 */ 
	public int getSubport() 
	{ 
4
CodeRank
This code example shows how to use the following methods:equals
        convict(endpoint, Double.MAX_VALUE);
    } 
 
    public void convict(InetAddress endpoint, double phi)
    { 
        if (!endpoint.equals(getHost()))
            return; 
 
        // We want a higher confidence in the failure detection than usual because failing a streaming wrongly has a high cost. 
        if (phi < 2 * DatabaseDescriptor.getPhiConvictThreshold())
            return; 
 
        logger.error("Stream failed because {} died or was restarted/removed (streams may still be active "
                      + "in background, but further streams won't be started)", endpoint);
        close(false); 
    } 
} 
4
CodeRank
This code example shows how to use the following methods:equals
		{ 
			return false; 
		} 
 
		final SerializableInternetProtocolAddress that = (SerializableInternetProtocolAddress) o;
		return address.equals(that.address);
	} 
 
	public int hashCode() 
	{ 
		return address.hashCode();
	} 
 
	@NotNull 
	public static <A extends InetAddress> SerializableInternetProtocolAddress<A> serializableInternetProtocolAddress(final @NotNull A address)
	{ 
		return new SerializableInternetProtocolAddress<A>(address);
	} 
 
	@NotNull 
4
CodeRank
This code example shows how to use the following methods:equals
			return false; 
		EngineIdentifier other = (EngineIdentifier) obj;
		if (address == null) {
			if (other.address != null)
				return false; 
		} else if (!address.equals(other.address))
			return false; 
		if (port != other.port)
			return false; 
		return true; 
	} 
} 
4
CodeRank
This code example shows how to use the following methods:equals
              + clientAddress + " tcpConnectionIp=" + connectedClientIp + ". Ignoring the packet.");
    } 
  } 
   
  private static synchronized boolean isCorrectIp(InetAddress clientAddress) {
    return clientAddress.equals(connectedClientIp);
  } 
 
  public static synchronized void setConnectedClientIp(InetAddress clientIp) {
    connectedClientIp = clientIp;
  } 
   
  /** 
   * Sends a packet to the client identifying our server's name and ip. 
   *  
   * @param multicastSocket 
   * @param packet 
   * @param data 
   *          Byte 0 is the packet id, bytes 1 to 4 is an int identifying the 
   *          port of the client to which we should send a reply. 
4
CodeRank
equals Method Overview
Compares this InetAddress instance against the specified address in obj.
See Code Examples for other Java 8 InetAddress Methods: