@Test public void testToHostIpSpace() { BDDInteger ipAddrBdd = BDDInteger.makeFromIndex(BDDUtils.bddFactory(32), 32, 0, true); IpSpaceToBDD toBDD = new IpSpaceToBDD(ipAddrBdd); assertThat( "/32 host space is preserved", toBDD.visit(Prefix.parse("1.2.3.4/32").toHostIpSpace()), equalTo(toBDD.visit(Prefix.parse("1.2.3.4/32").toIpSpace()))); assertThat( "/31 host space is preserved", toBDD.visit(Prefix.parse("1.2.3.4/31").toHostIpSpace()), equalTo(toBDD.visit(Prefix.parse("1.2.3.4/31").toIpSpace()))); BDD slash30Filtered = toBDD .visit(Ip.parse("1.2.3.5").toIpSpace()) .or(toBDD.visit(Ip.parse("1.2.3.6").toIpSpace())); assertThat( "/30 host space is two IPs", toBDD.visit(Prefix.parse("1.2.3.4/30").toHostIpSpace()), equalTo(slash30Filtered)); }
public IpSpace toHostIpSpace() { if (_prefixLength >= Prefix.MAX_PREFIX_LENGTH - 1) { return toIpSpace(); } return AclIpSpace.builder() .thenRejecting(getStartIp().toIpSpace()) .thenRejecting(getEndIp().toIpSpace()) .thenPermitting(toIpSpace()) .build(); }
Prefix implements Comparable<Prefix>, Serializable { public IpSpace toHostIpSpace() { if (_prefixLength >= Prefix.MAX_PREFIX_LENGTH - 1) { return toIpSpace(); } return AclIpSpace.builder() .thenRejecting(getStartIp().toIpSpace()) .thenRejecting(getEndIp().toIpSpace()) .thenPermitting(toIpSpace()) .build(); } }
Prefix implements Comparable<Prefix>, Serializable { public IpSpace toHostIpSpace() { if (_prefixLength >= Prefix.MAX_PREFIX_LENGTH - 1) { return toIpSpace(); } return AclIpSpace.builder() .thenRejecting(getStartIp().toIpSpace()) .thenRejecting(getEndIp().toIpSpace()) .thenPermitting(toIpSpace()) .build(); } private  Prefix(Ip ip, int prefixLength); }
Prefix implements Comparable<Prefix>, Serializable { public IpSpace toHostIpSpace() { if (_prefixLength >= Prefix.MAX_PREFIX_LENGTH - 1) { return toIpSpace(); } return AclIpSpace.builder() .thenRejecting(getStartIp().toIpSpace()) .thenRejecting(getEndIp().toIpSpace()) .thenPermitting(toIpSpace()) .build(); } 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 { public IpSpace toHostIpSpace() { if (_prefixLength >= Prefix.MAX_PREFIX_LENGTH - 1) { return toIpSpace(); } return AclIpSpace.builder() .thenRejecting(getStartIp().toIpSpace()) .thenRejecting(getEndIp().toIpSpace()) .thenPermitting(toIpSpace()) .build(); } 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; }