@Test public void testInvalidPrefix() { _thrown.expectMessage("Invalid prefix length"); _thrown.expect(IllegalArgumentException.class); Prefix.parse("1.1.1.1/33"); }
@Nonnull @JsonCreator public static Prefix parse(@Nullable String text) { checkArgument(text != null, "Invalid IPv4 prefix %s", text); String[] parts = text.split("/"); checkArgument(parts.length == 2, "Invalid prefix string: \"%s\"", text); Ip ip = Ip.parse(parts[0]); int prefixLength; try { prefixLength = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid prefix length: \"" + parts[1] + "\"", e); } return create(ip, prefixLength); }
Prefix implements Comparable<Prefix>, Serializable { @Nonnull @JsonCreator public static Prefix parse(@Nullable String text) { checkArgument(text != null, "Invalid IPv4 prefix %s", text); String[] parts = text.split("/"); checkArgument(parts.length == 2, "Invalid prefix string: \"%s\"", text); Ip ip = Ip.parse(parts[0]); int prefixLength; try { prefixLength = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid prefix length: \"" + parts[1] + "\"", e); } return create(ip, prefixLength); } }
Prefix implements Comparable<Prefix>, Serializable { @Nonnull @JsonCreator public static Prefix parse(@Nullable String text) { checkArgument(text != null, "Invalid IPv4 prefix %s", text); String[] parts = text.split("/"); checkArgument(parts.length == 2, "Invalid prefix string: \"%s\"", text); Ip ip = Ip.parse(parts[0]); int prefixLength; try { prefixLength = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid prefix length: \"" + parts[1] + "\"", e); } return create(ip, prefixLength); } private  Prefix(Ip ip, int prefixLength); }
Prefix implements Comparable<Prefix>, Serializable { @Nonnull @JsonCreator public static Prefix parse(@Nullable String text) { checkArgument(text != null, "Invalid IPv4 prefix %s", text); String[] parts = text.split("/"); checkArgument(parts.length == 2, "Invalid prefix string: \"%s\"", text); Ip ip = Ip.parse(parts[0]); int prefixLength; try { prefixLength = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid prefix length: \"" + parts[1] + "\"", e); } return create(ip, prefixLength); } private  Prefix(Ip ip, int prefixLength); @Nonnull @JsonCreator static Prefix parse(@Nullable String text); @Nonnull static Optional<Prefix> tryParse(@Nonnull String text); static @Nonnull Prefix strict(String prefixStr); static Prefix create(Ip ip, int prefixLength); static Prefix create(Ip address, Ip mask); static Prefix longestCommonPrefix(Prefix p1, Prefix p2); @Override int compareTo(Prefix rhs); boolean containsIp(Ip ip); boolean containsPrefix(Prefix prefix); @Override boolean equals(@Nullable Object o); @Nonnull Ip getEndIp(); int getPrefixLength(); @Nonnull Ip getPrefixWildcard(); @Nonnull Ip getStartIp(); @Override int hashCode(); @Nonnull IpSpace toIpSpace(); IpSpace toHostIpSpace(); Ip getFirstHostIp(); Ip getLastHostIp(); @Override @JsonValue String toString(); }
Prefix implements Comparable<Prefix>, Serializable { @Nonnull @JsonCreator public static Prefix parse(@Nullable String text) { checkArgument(text != null, "Invalid IPv4 prefix %s", text); String[] parts = text.split("/"); checkArgument(parts.length == 2, "Invalid prefix string: \"%s\"", text); Ip ip = Ip.parse(parts[0]); int prefixLength; try { prefixLength = Integer.parseInt(parts[1]); } catch (NumberFormatException e) { throw new IllegalArgumentException("Invalid prefix length: \"" + parts[1] + "\"", e); } return create(ip, prefixLength); } private  Prefix(Ip ip, int prefixLength); @Nonnull @JsonCreator static Prefix parse(@Nullable String text); @Nonnull static Optional<Prefix> tryParse(@Nonnull String text); static @Nonnull Prefix strict(String prefixStr); static Prefix create(Ip ip, int prefixLength); static Prefix create(Ip address, Ip mask); static Prefix longestCommonPrefix(Prefix p1, Prefix p2); @Override int compareTo(Prefix rhs); boolean containsIp(Ip ip); boolean containsPrefix(Prefix prefix); @Override boolean equals(@Nullable Object o); @Nonnull Ip getEndIp(); int getPrefixLength(); @Nonnull Ip getPrefixWildcard(); @Nonnull Ip getStartIp(); @Override int hashCode(); @Nonnull IpSpace toIpSpace(); IpSpace toHostIpSpace(); Ip getFirstHostIp(); Ip getLastHostIp(); @Override @JsonValue String toString(); static final int MAX_PREFIX_LENGTH; static final Prefix ZERO; static final Prefix MULTICAST; static final int HOST_SUBNET_MAX_PREFIX_LENGTH; }