@Test public void testContainsAddress() { assertTrue(containsAddress("0.0.0.0/0", "0.0.0.0")); assertTrue(containsAddress("0.0.0.0/0", "1.2.3.4")); assertTrue(containsAddress("0.0.0.0/0", "255.255.255.255")); assertTrue(containsAddress("8.8.8.0/24", "8.8.8.0")); assertTrue(containsAddress("8.8.8.0/24", "8.8.8.8")); assertTrue(containsAddress("8.8.8.0/24", "8.8.8.255")); assertTrue(containsAddress("202.12.128.0/18", "202.12.128.0")); assertTrue(containsAddress("202.12.128.0/18", "202.12.128.255")); assertTrue(containsAddress("202.12.128.0/18", "202.12.157.123")); assertTrue(containsAddress("202.12.128.0/18", "202.12.191.255")); assertFalse(containsAddress("8.8.8.0/24", "8.8.9.0")); assertFalse(containsAddress("8.8.8.8/32", "8.8.8.9")); assertFalse(containsAddress("202.12.128.0/18", "202.12.127.255")); assertFalse(containsAddress("202.12.128.0/18", "202.12.192.0")); }
public boolean containsAddress(Inet4Address address) { long ip = addressToLong(address); return (ip >= start) && (ip <= end); }
Inet4Network { public boolean containsAddress(Inet4Address address) { long ip = addressToLong(address); return (ip >= start) && (ip <= end); } }
Inet4Network { public boolean containsAddress(Inet4Address address) { long ip = addressToLong(address); return (ip >= start) && (ip <= end); } private  Inet4Network(Inet4Address address, int bits); }
Inet4Network { public boolean containsAddress(Inet4Address address) { long ip = addressToLong(address); return (ip >= start) && (ip <= end); } private  Inet4Network(Inet4Address address, int bits); boolean containsAddress(Inet4Address address); @Override String toString(); @Override @SuppressWarnings("RedundantIfStatement") boolean equals(Object o); @Override int hashCode(); @SuppressWarnings("StringSplitter") static Inet4Network fromCidr(String cidr); }
Inet4Network { public boolean containsAddress(Inet4Address address) { long ip = addressToLong(address); return (ip >= start) && (ip <= end); } private  Inet4Network(Inet4Address address, int bits); boolean containsAddress(Inet4Address address); @Override String toString(); @Override @SuppressWarnings("RedundantIfStatement") boolean equals(Object o); @Override int hashCode(); @SuppressWarnings("StringSplitter") static Inet4Network fromCidr(String cidr);  }