@Test public void testDeSerialization() throws IOException { PrefixRange pr = PrefixRange.fromString("1.2.3.4/8:17-19"); assertThat( BatfishObjectMapper.mapper().readValue("\"1.0.0.0/8:17-19\"", PrefixRange.class), equalTo(pr)); }
@JsonCreator public static PrefixRange fromString(String prefixRangeStr) { String[] parts = prefixRangeStr.split(":"); if (parts.length == 1) { return fromPrefix(Prefix.parse(parts[0])); } else if (parts.length == 2) { return new PrefixRange(Prefix.parse(parts[0]), new SubRange(parts[1])); } else { throw new BatfishException("Invalid PrefixRange string: '" + prefixRangeStr + "'"); } }
PrefixRange implements Serializable, Comparable<PrefixRange> { @JsonCreator public static PrefixRange fromString(String prefixRangeStr) { String[] parts = prefixRangeStr.split(":"); if (parts.length == 1) { return fromPrefix(Prefix.parse(parts[0])); } else if (parts.length == 2) { return new PrefixRange(Prefix.parse(parts[0]), new SubRange(parts[1])); } else { throw new BatfishException("Invalid PrefixRange string: '" + prefixRangeStr + "'"); } } }
PrefixRange implements Serializable, Comparable<PrefixRange> { @JsonCreator public static PrefixRange fromString(String prefixRangeStr) { String[] parts = prefixRangeStr.split(":"); if (parts.length == 1) { return fromPrefix(Prefix.parse(parts[0])); } else if (parts.length == 2) { return new PrefixRange(Prefix.parse(parts[0]), new SubRange(parts[1])); } else { throw new BatfishException("Invalid PrefixRange string: '" + prefixRangeStr + "'"); } } PrefixRange(Prefix prefix, SubRange lengthRange); }
PrefixRange implements Serializable, Comparable<PrefixRange> { @JsonCreator public static PrefixRange fromString(String prefixRangeStr) { String[] parts = prefixRangeStr.split(":"); if (parts.length == 1) { return fromPrefix(Prefix.parse(parts[0])); } else if (parts.length == 2) { return new PrefixRange(Prefix.parse(parts[0]), new SubRange(parts[1])); } else { throw new BatfishException("Invalid PrefixRange string: '" + prefixRangeStr + "'"); } } PrefixRange(Prefix prefix, SubRange lengthRange); static PrefixRange fromPrefix(Prefix prefix); @JsonCreator static PrefixRange fromString(String prefixRangeStr); static PrefixRange moreSpecificThan(Prefix prefix); SubRange getLengthRange(); Prefix getPrefix(); boolean includesPrefixRange(PrefixRange argPrefixRange); @Override @JsonValue String toString(); @Override int compareTo(@Nonnull PrefixRange o); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); }
PrefixRange implements Serializable, Comparable<PrefixRange> { @JsonCreator public static PrefixRange fromString(String prefixRangeStr) { String[] parts = prefixRangeStr.split(":"); if (parts.length == 1) { return fromPrefix(Prefix.parse(parts[0])); } else if (parts.length == 2) { return new PrefixRange(Prefix.parse(parts[0]), new SubRange(parts[1])); } else { throw new BatfishException("Invalid PrefixRange string: '" + prefixRangeStr + "'"); } } PrefixRange(Prefix prefix, SubRange lengthRange); static PrefixRange fromPrefix(Prefix prefix); @JsonCreator static PrefixRange fromString(String prefixRangeStr); static PrefixRange moreSpecificThan(Prefix prefix); SubRange getLengthRange(); Prefix getPrefix(); boolean includesPrefixRange(PrefixRange argPrefixRange); @Override @JsonValue String toString(); @Override int compareTo(@Nonnull PrefixRange o); @Override int hashCode(); @Override boolean equals(@Nullable Object obj); static final PrefixRange ALL; }