### Question:
Netmask { public static @Nullable Netmask fromCidr(String cidr) { String[] parts = cidr.split("/"); if (parts.length == 2 && InetAddresses.isInetAddress(parts[0])) { Integer prefixLength = Ints.tryParse(parts[1]); if (prefixLength != null) { return new Netmask(parts[0], prefixLength); } } return null; } @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);  }### Answer:
@Test public void fromCidr() { assertEquals(netmask("1.1.1.1", 32), Netmask.fromCidr("1.1.1.1/32")); }
@Test public void fromCidr_noRoutingPrefixLength() { assertNull(Netmask.fromCidr("1.1.1.1")); }
@Test public void fromCidr_tooManySlashes() { assertNull(Netmask.fromCidr("1.1.1.1/3/2")); }
@Test public void fromCidr_invalidRoutingPrefixLength() { assertNull(Netmask.fromCidr("1.1.1.1/abc")); }
@Test public void fromCidr_invalidNetworkAddress() { assertNull(Netmask.fromCidr("abc/32")); }