@Test public void testCompareTo() { List<BgpPeerConfigId> ordered = ImmutableList.of( new BgpPeerConfigId("c0", "vrf0", Prefix.ZERO, false), new BgpPeerConfigId("c1", "vrf0", Prefix.ZERO, false), new BgpPeerConfigId("c1", "vrf1", Prefix.ZERO, false), new BgpPeerConfigId("c1", "vrf1", Prefix.parse("1.1.1.1/24"), false), new BgpPeerConfigId("c1", "vrf1", Prefix.parse("1.1.1.1/24"), true), new BgpPeerConfigId("c2", "vrf1", Prefix.parse("1.1.1.1/24"), true), new BgpPeerConfigId("c2", "vrf2", Prefix.parse("1.1.1.1/24"), true), new BgpPeerConfigId("c2", "vrf2", Prefix.parse("2.2.2.2/24"), true), new BgpPeerConfigId("c2", "vrf2", "iface"), new BgpPeerConfigId("c3", "vrf2", "iface"), new BgpPeerConfigId("c3", "vrf3", "iface"), new BgpPeerConfigId("c3", "vrf3", "iface2")); for (int i = 0; i < ordered.size(); i++) { for (int j = 0; j < ordered.size(); j++) { assertThat( Integer.signum(ordered.get(i).compareTo(ordered.get(j))), equalTo(Integer.signum(i - j))); } } }
@Override public int compareTo(@Nonnull BgpPeerConfigId o) { return Comparator.comparing(BgpPeerConfigId::getHostname) .thenComparing(BgpPeerConfigId::getVrfName) .thenComparing(BgpPeerConfigId::getType) .thenComparing( BgpPeerConfigId::getRemotePeerPrefix, Comparator.nullsLast(Prefix::compareTo)) .thenComparing( BgpPeerConfigId::getPeerInterface, Comparator.nullsLast(Comparator.naturalOrder())) .compare(this, o); }
BgpPeerConfigId implements Comparable<BgpPeerConfigId> { @Override public int compareTo(@Nonnull BgpPeerConfigId o) { return Comparator.comparing(BgpPeerConfigId::getHostname) .thenComparing(BgpPeerConfigId::getVrfName) .thenComparing(BgpPeerConfigId::getType) .thenComparing( BgpPeerConfigId::getRemotePeerPrefix, Comparator.nullsLast(Prefix::compareTo)) .thenComparing( BgpPeerConfigId::getPeerInterface, Comparator.nullsLast(Comparator.naturalOrder())) .compare(this, o); } }
BgpPeerConfigId implements Comparable<BgpPeerConfigId> { @Override public int compareTo(@Nonnull BgpPeerConfigId o) { return Comparator.comparing(BgpPeerConfigId::getHostname) .thenComparing(BgpPeerConfigId::getVrfName) .thenComparing(BgpPeerConfigId::getType) .thenComparing( BgpPeerConfigId::getRemotePeerPrefix, Comparator.nullsLast(Prefix::compareTo)) .thenComparing( BgpPeerConfigId::getPeerInterface, Comparator.nullsLast(Comparator.naturalOrder())) .compare(this, o); } BgpPeerConfigId(
      @Nonnull String hostname,
      @Nonnull String vrfName,
      @Nonnull Prefix remotePeerPrefix,
      boolean dynamic);  BgpPeerConfigId(
      @Nonnull String hostname, @Nonnull String vrfName, @Nonnull String peerInterface); }
BgpPeerConfigId implements Comparable<BgpPeerConfigId> { @Override public int compareTo(@Nonnull BgpPeerConfigId o) { return Comparator.comparing(BgpPeerConfigId::getHostname) .thenComparing(BgpPeerConfigId::getVrfName) .thenComparing(BgpPeerConfigId::getType) .thenComparing( BgpPeerConfigId::getRemotePeerPrefix, Comparator.nullsLast(Prefix::compareTo)) .thenComparing( BgpPeerConfigId::getPeerInterface, Comparator.nullsLast(Comparator.naturalOrder())) .compare(this, o); } BgpPeerConfigId(
      @Nonnull String hostname,
      @Nonnull String vrfName,
      @Nonnull Prefix remotePeerPrefix,
      boolean dynamic);  BgpPeerConfigId(
      @Nonnull String hostname, @Nonnull String vrfName, @Nonnull String peerInterface); @Nonnull @JsonProperty(PROP_HOSTNAME) String getHostname(); @Nonnull @JsonProperty(PROP_VRF_NAME) String getVrfName(); @Nullable @JsonProperty(PROP_INTERFACE) String getPeerInterface(); @Nullable @JsonProperty(PROP_PREFIX) Prefix getRemotePeerPrefix(); @Nonnull @JsonProperty(PROP_TYPE) BgpPeerConfigType getType(); @Override int compareTo(@Nonnull BgpPeerConfigId o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
BgpPeerConfigId implements Comparable<BgpPeerConfigId> { @Override public int compareTo(@Nonnull BgpPeerConfigId o) { return Comparator.comparing(BgpPeerConfigId::getHostname) .thenComparing(BgpPeerConfigId::getVrfName) .thenComparing(BgpPeerConfigId::getType) .thenComparing( BgpPeerConfigId::getRemotePeerPrefix, Comparator.nullsLast(Prefix::compareTo)) .thenComparing( BgpPeerConfigId::getPeerInterface, Comparator.nullsLast(Comparator.naturalOrder())) .compare(this, o); } BgpPeerConfigId(
      @Nonnull String hostname,
      @Nonnull String vrfName,
      @Nonnull Prefix remotePeerPrefix,
      boolean dynamic);  BgpPeerConfigId(
      @Nonnull String hostname, @Nonnull String vrfName, @Nonnull String peerInterface); @Nonnull @JsonProperty(PROP_HOSTNAME) String getHostname(); @Nonnull @JsonProperty(PROP_VRF_NAME) String getVrfName(); @Nullable @JsonProperty(PROP_INTERFACE) String getPeerInterface(); @Nullable @JsonProperty(PROP_PREFIX) Prefix getRemotePeerPrefix(); @Nonnull @JsonProperty(PROP_TYPE) BgpPeerConfigType getType(); @Override int compareTo(@Nonnull BgpPeerConfigId o); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }