@Test public void fromCidr_invalidNetworkAddress() { assertNull(Netmask.fromCidr("abc/32")); }
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; }
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; } }
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); }
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); }
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);  }