@Test public void equals() { new EqualsTester() .addEqualityGroup(netmask("1.1.1.1", 32), netmask("1.1.1.1", 32)) .addEqualityGroup(netmask("1.1.1.1", 24)) .addEqualityGroup(netmask("2.2.2.2", 32)) .testEquals(); }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; } return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); }
Netmask { @Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; } return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); } }
Netmask { @Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; } return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); } @VisibleForTesting  Netmask(String networkAddress, int routingPrefixLength); }
Netmask { @Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; } return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); } @VisibleForTesting  Netmask(String networkAddress, int routingPrefixLength); static @Nullable Netmask fromCidr(String cidr); static ImmutableSet<Netmask> fromCidr(Collection<String> cidrs); static ImmutableSet<String> toCidr(Collection<Netmask> netmasks); String toCidr(); String getNetworkAddress(); int getRoutingPrefixLength(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
Netmask { @Override public boolean equals(Object obj) { if (obj == null) { return false; } else if (obj == this) { return true; } else if (!getClass().isAssignableFrom(obj.getClass())) { return false; } return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes()); } @VisibleForTesting  Netmask(String networkAddress, int routingPrefixLength); static @Nullable Netmask fromCidr(String cidr); static ImmutableSet<Netmask> fromCidr(Collection<String> cidrs); static ImmutableSet<String> toCidr(Collection<Netmask> netmasks); String toCidr(); String getNetworkAddress(); int getRoutingPrefixLength(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }