@Test public void testInheritFrom() { BgpPeerGroupNeighbor pg = new BgpPeerGroupNeighbor("pg"); pg.setBgpNeighborSource(new BgpNeighborSourceAddress(Ip.MAX)); pg.setDescription("pg desc"); pg.setEbgpMultihop(5L); BgpNeighborIpv4UnicastAddressFamily pgIpv4 = new BgpNeighborIpv4UnicastAddressFamily(); pgIpv4.setNextHopSelf(true); pg.setIpv4UnicastAddressFamily(pgIpv4); BgpNeighborL2vpnEvpnAddressFamily pgL2vpn = new BgpNeighborL2vpnEvpnAddressFamily(); pgL2vpn.setRouteReflectorClient(true); pg.setL2vpnEvpnAddressFamily(pgL2vpn); pg.setRemoteAs(8L); pg.setRemoteAsType(RemoteAsType.EXPLICIT); { BgpIpNeighbor leaf = new BgpIpNeighbor("leaf"); leaf.setBgpNeighborSource(new BgpNeighborSourceAddress(Ip.ZERO)); leaf.setDescription("leaf desc"); leaf.setEbgpMultihop(1L); BgpNeighborIpv4UnicastAddressFamily leafIpv4 = new BgpNeighborIpv4UnicastAddressFamily(); leafIpv4.setNextHopSelf(false); leaf.setIpv4UnicastAddressFamily(leafIpv4); BgpNeighborL2vpnEvpnAddressFamily leafL2vpn = new BgpNeighborL2vpnEvpnAddressFamily(); leafL2vpn.setRouteReflectorClient(false); leaf.setL2vpnEvpnAddressFamily(leafL2vpn); leaf.setPeerGroup("pg"); leaf.setRemoteAsType(RemoteAsType.EXTERNAL); leaf.inheritFrom(ImmutableMap.of("pg", pg)); assertThat(leaf.getBgpNeighborSource(), equalTo(new BgpNeighborSourceAddress(Ip.ZERO))); assertThat(leaf.getDescription(), equalTo("leaf desc")); assertThat(leaf.getEbgpMultihop(), equalTo(1L)); assertThat(leaf.getIpv4UnicastAddressFamily().getNextHopSelf(), not(equalTo(Boolean.TRUE))); assertThat( leaf.getL2vpnEvpnAddressFamily().getRouteReflectorClient(), not(equalTo(Boolean.TRUE))); assertThat(leaf.getPeerGroup(), equalTo("pg")); assertThat(leaf.getRemoteAs(), nullValue()); assertThat(leaf.getRemoteAsType(), equalTo(RemoteAsType.EXTERNAL)); } { BgpIpNeighbor leaf = new BgpIpNeighbor("leaf"); leaf.setPeerGroup("pg"); leaf.inheritFrom(ImmutableMap.of("pg", pg)); assertThat(leaf.getBgpNeighborSource(), equalTo(new BgpNeighborSourceAddress(Ip.MAX))); assertThat(leaf.getDescription(), nullValue()); assertThat(leaf.getEbgpMultihop(), equalTo(5L)); assertThat(leaf.getIpv4UnicastAddressFamily().getNextHopSelf(), equalTo(Boolean.TRUE)); assertThat(leaf.getL2vpnEvpnAddressFamily().getRouteReflectorClient(), equalTo(Boolean.TRUE)); assertThat(leaf.getRemoteAs(), equalTo(8L)); assertThat(leaf.getRemoteAsType(), equalTo(RemoteAsType.EXPLICIT)); } }
protected void inheritFrom(@Nonnull Map<String, BgpNeighbor> peers) { if (_inherited) { return; } _inherited = true; @Nullable BgpNeighbor other = _peerGroup == null ? null : peers.get(_peerGroup); if (other == null) { return; } if (_bgpNeighborSource == null) { _bgpNeighborSource = other.getBgpNeighborSource(); } if (_ebgpMultihop == null) { _ebgpMultihop = other.getEbgpMultihop(); } if (_remoteAsType == null) { _remoteAs = other.getRemoteAs(); _remoteAsType = other.getRemoteAsType(); } if (_ipv4UnicastAddressFamily == null) { _ipv4UnicastAddressFamily = other.getIpv4UnicastAddressFamily(); } else if (other.getIpv4UnicastAddressFamily() != null) { _ipv4UnicastAddressFamily.inheritFrom(other.getIpv4UnicastAddressFamily()); } if (_l2vpnEvpnAddressFamily == null) { _l2vpnEvpnAddressFamily = other.getL2vpnEvpnAddressFamily(); } else if (other.getL2vpnEvpnAddressFamily() != null) { _l2vpnEvpnAddressFamily.inheritFrom(other.getL2vpnEvpnAddressFamily()); } if (_localAs == null) { _localAs = other.getLocalAs(); } }
BgpNeighbor implements Serializable { protected void inheritFrom(@Nonnull Map<String, BgpNeighbor> peers) { if (_inherited) { return; } _inherited = true; @Nullable BgpNeighbor other = _peerGroup == null ? null : peers.get(_peerGroup); if (other == null) { return; } if (_bgpNeighborSource == null) { _bgpNeighborSource = other.getBgpNeighborSource(); } if (_ebgpMultihop == null) { _ebgpMultihop = other.getEbgpMultihop(); } if (_remoteAsType == null) { _remoteAs = other.getRemoteAs(); _remoteAsType = other.getRemoteAsType(); } if (_ipv4UnicastAddressFamily == null) { _ipv4UnicastAddressFamily = other.getIpv4UnicastAddressFamily(); } else if (other.getIpv4UnicastAddressFamily() != null) { _ipv4UnicastAddressFamily.inheritFrom(other.getIpv4UnicastAddressFamily()); } if (_l2vpnEvpnAddressFamily == null) { _l2vpnEvpnAddressFamily = other.getL2vpnEvpnAddressFamily(); } else if (other.getL2vpnEvpnAddressFamily() != null) { _l2vpnEvpnAddressFamily.inheritFrom(other.getL2vpnEvpnAddressFamily()); } if (_localAs == null) { _localAs = other.getLocalAs(); } } }
BgpNeighbor implements Serializable { protected void inheritFrom(@Nonnull Map<String, BgpNeighbor> peers) { if (_inherited) { return; } _inherited = true; @Nullable BgpNeighbor other = _peerGroup == null ? null : peers.get(_peerGroup); if (other == null) { return; } if (_bgpNeighborSource == null) { _bgpNeighborSource = other.getBgpNeighborSource(); } if (_ebgpMultihop == null) { _ebgpMultihop = other.getEbgpMultihop(); } if (_remoteAsType == null) { _remoteAs = other.getRemoteAs(); _remoteAsType = other.getRemoteAsType(); } if (_ipv4UnicastAddressFamily == null) { _ipv4UnicastAddressFamily = other.getIpv4UnicastAddressFamily(); } else if (other.getIpv4UnicastAddressFamily() != null) { _ipv4UnicastAddressFamily.inheritFrom(other.getIpv4UnicastAddressFamily()); } if (_l2vpnEvpnAddressFamily == null) { _l2vpnEvpnAddressFamily = other.getL2vpnEvpnAddressFamily(); } else if (other.getL2vpnEvpnAddressFamily() != null) { _l2vpnEvpnAddressFamily.inheritFrom(other.getL2vpnEvpnAddressFamily()); } if (_localAs == null) { _localAs = other.getLocalAs(); } } BgpNeighbor(String name); }
BgpNeighbor implements Serializable { protected void inheritFrom(@Nonnull Map<String, BgpNeighbor> peers) { if (_inherited) { return; } _inherited = true; @Nullable BgpNeighbor other = _peerGroup == null ? null : peers.get(_peerGroup); if (other == null) { return; } if (_bgpNeighborSource == null) { _bgpNeighborSource = other.getBgpNeighborSource(); } if (_ebgpMultihop == null) { _ebgpMultihop = other.getEbgpMultihop(); } if (_remoteAsType == null) { _remoteAs = other.getRemoteAs(); _remoteAsType = other.getRemoteAsType(); } if (_ipv4UnicastAddressFamily == null) { _ipv4UnicastAddressFamily = other.getIpv4UnicastAddressFamily(); } else if (other.getIpv4UnicastAddressFamily() != null) { _ipv4UnicastAddressFamily.inheritFrom(other.getIpv4UnicastAddressFamily()); } if (_l2vpnEvpnAddressFamily == null) { _l2vpnEvpnAddressFamily = other.getL2vpnEvpnAddressFamily(); } else if (other.getL2vpnEvpnAddressFamily() != null) { _l2vpnEvpnAddressFamily.inheritFrom(other.getL2vpnEvpnAddressFamily()); } if (_localAs == null) { _localAs = other.getLocalAs(); } } BgpNeighbor(String name); @Nonnull String getName(); @Nullable String getDescription(); void setDescription(@Nullable String description); @Nullable BgpNeighborIpv4UnicastAddressFamily getIpv4UnicastAddressFamily(); BgpNeighbor setIpv4UnicastAddressFamily(
      @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily); @Nullable BgpNeighborL2vpnEvpnAddressFamily getL2vpnEvpnAddressFamily(); BgpNeighbor setL2vpnEvpnAddressFamily(
      @Nullable BgpNeighborL2vpnEvpnAddressFamily l2vpnEvpnAddressFamily); @Nullable String getPeerGroup(); void setPeerGroup(@Nullable String peerGroup); @Nullable Long getLocalAs(); @Nullable Long getRemoteAs(); @Nullable RemoteAsType getRemoteAsType(); @Nullable Long getEbgpMultihop(); void setEbgpMultihop(@Nullable Long ebgpMultihop); void setLocalAs(@Nullable Long localAs); void setRemoteAs(@Nullable Long remoteAs); void setRemoteAsType(@Nullable RemoteAsType remoteAsType); @Nullable BgpNeighborSource getBgpNeighborSource(); void setBgpNeighborSource(@Nullable BgpNeighborSource bgpNeighborSource); }
BgpNeighbor implements Serializable { protected void inheritFrom(@Nonnull Map<String, BgpNeighbor> peers) { if (_inherited) { return; } _inherited = true; @Nullable BgpNeighbor other = _peerGroup == null ? null : peers.get(_peerGroup); if (other == null) { return; } if (_bgpNeighborSource == null) { _bgpNeighborSource = other.getBgpNeighborSource(); } if (_ebgpMultihop == null) { _ebgpMultihop = other.getEbgpMultihop(); } if (_remoteAsType == null) { _remoteAs = other.getRemoteAs(); _remoteAsType = other.getRemoteAsType(); } if (_ipv4UnicastAddressFamily == null) { _ipv4UnicastAddressFamily = other.getIpv4UnicastAddressFamily(); } else if (other.getIpv4UnicastAddressFamily() != null) { _ipv4UnicastAddressFamily.inheritFrom(other.getIpv4UnicastAddressFamily()); } if (_l2vpnEvpnAddressFamily == null) { _l2vpnEvpnAddressFamily = other.getL2vpnEvpnAddressFamily(); } else if (other.getL2vpnEvpnAddressFamily() != null) { _l2vpnEvpnAddressFamily.inheritFrom(other.getL2vpnEvpnAddressFamily()); } if (_localAs == null) { _localAs = other.getLocalAs(); } } BgpNeighbor(String name); @Nonnull String getName(); @Nullable String getDescription(); void setDescription(@Nullable String description); @Nullable BgpNeighborIpv4UnicastAddressFamily getIpv4UnicastAddressFamily(); BgpNeighbor setIpv4UnicastAddressFamily(
      @Nullable BgpNeighborIpv4UnicastAddressFamily ipv4UnicastAddressFamily); @Nullable BgpNeighborL2vpnEvpnAddressFamily getL2vpnEvpnAddressFamily(); BgpNeighbor setL2vpnEvpnAddressFamily(
      @Nullable BgpNeighborL2vpnEvpnAddressFamily l2vpnEvpnAddressFamily); @Nullable String getPeerGroup(); void setPeerGroup(@Nullable String peerGroup); @Nullable Long getLocalAs(); @Nullable Long getRemoteAs(); @Nullable RemoteAsType getRemoteAsType(); @Nullable Long getEbgpMultihop(); void setEbgpMultihop(@Nullable Long ebgpMultihop); void setLocalAs(@Nullable Long localAs); void setRemoteAs(@Nullable Long remoteAs); void setRemoteAsType(@Nullable RemoteAsType remoteAsType); @Nullable BgpNeighborSource getBgpNeighborSource(); void setBgpNeighborSource(@Nullable BgpNeighborSource bgpNeighborSource);  }