@Test public void testGetVrf() { Configuration c = new Configuration("foo", ConfigurationFormat.CISCO_IOS); c.getVrfs().put("fooVRF", new Vrf("fooVRF")); NetworkConfigurations nc = NetworkConfigurations.of(ImmutableMap.of("foo", c)); assertThat(nc.getVrf("missingHostname", "missingVRF"), equalTo(Optional.empty())); assertThat(nc.getVrf("missingHostname", "fooVRF"), equalTo(Optional.empty())); assertThat(nc.getVrf("foo", "missingVRF"), equalTo(Optional.empty())); assertTrue("VRF is present", nc.getVrf("foo", "fooVRF").isPresent()); }
public Optional<Vrf> getVrf(String hostname, String vrfName) { return get(hostname).map(Configuration::getVrfs).map(m -> m.get(vrfName)); }
NetworkConfigurations { public Optional<Vrf> getVrf(String hostname, String vrfName) { return get(hostname).map(Configuration::getVrfs).map(m -> m.get(vrfName)); } }
NetworkConfigurations { public Optional<Vrf> getVrf(String hostname, String vrfName) { return get(hostname).map(Configuration::getVrfs).map(m -> m.get(vrfName)); } private  NetworkConfigurations(Map<String, Configuration> configurations); }
NetworkConfigurations { public Optional<Vrf> getVrf(String hostname, String vrfName) { return get(hostname).map(Configuration::getVrfs).map(m -> m.get(vrfName)); } private  NetworkConfigurations(Map<String, Configuration> configurations); @Nonnull Map<String, Configuration> getMap(); @Nonnull Collection<Configuration> all(); @Nonnull Optional<Configuration> get(String hostname); @Nullable BgpPeerConfig getBgpPeerConfig(BgpPeerConfigId id); @Nullable BgpPassivePeerConfig getBgpDynamicPeerConfig(BgpPeerConfigId id); @Nullable BgpActivePeerConfig getBgpPointToPointPeerConfig(BgpPeerConfigId id); @Nullable BgpUnnumberedPeerConfig getBgpUnnumberedPeerConfig(BgpPeerConfigId id); Optional<EigrpNeighborConfig> getEigrpNeighborConfig(EigrpNeighborConfigId eigrpConfigId); @Nonnull Optional<Interface> getInterface(String hostname, String interfaceName); @Nullable IpsecPeerConfig getIpsecPeerConfig(IpsecPeerConfigId ipsecPeerConfigId); @Nonnull Optional<Mlag> getMlagConfig(String hostname, String id); @Nonnull Optional<OspfProcess> getOspfProcess(String hostname, String interfaceName); @Nonnull Optional<OspfProcess> getOspfProcess(OspfNeighborConfigId ospfConfigId); Optional<OspfNeighborConfig> getOspfNeighborConfig(OspfNeighborConfigId ospfConfigId); @Nonnull Optional<Layer2Vni> getVniSettings(String hostname, int vni); Optional<Vrf> getVrf(String hostname, String vrfName); static NetworkConfigurations of(Map<String, Configuration> configurations); @Nonnull Optional<Stream<OspfNeighborConfigId>> getOspfNeighborConfigs(
      String hostname, String interfaceName); }
NetworkConfigurations { public Optional<Vrf> getVrf(String hostname, String vrfName) { return get(hostname).map(Configuration::getVrfs).map(m -> m.get(vrfName)); } private  NetworkConfigurations(Map<String, Configuration> configurations); @Nonnull Map<String, Configuration> getMap(); @Nonnull Collection<Configuration> all(); @Nonnull Optional<Configuration> get(String hostname); @Nullable BgpPeerConfig getBgpPeerConfig(BgpPeerConfigId id); @Nullable BgpPassivePeerConfig getBgpDynamicPeerConfig(BgpPeerConfigId id); @Nullable BgpActivePeerConfig getBgpPointToPointPeerConfig(BgpPeerConfigId id); @Nullable BgpUnnumberedPeerConfig getBgpUnnumberedPeerConfig(BgpPeerConfigId id); Optional<EigrpNeighborConfig> getEigrpNeighborConfig(EigrpNeighborConfigId eigrpConfigId); @Nonnull Optional<Interface> getInterface(String hostname, String interfaceName); @Nullable IpsecPeerConfig getIpsecPeerConfig(IpsecPeerConfigId ipsecPeerConfigId); @Nonnull Optional<Mlag> getMlagConfig(String hostname, String id); @Nonnull Optional<OspfProcess> getOspfProcess(String hostname, String interfaceName); @Nonnull Optional<OspfProcess> getOspfProcess(OspfNeighborConfigId ospfConfigId); Optional<OspfNeighborConfig> getOspfNeighborConfig(OspfNeighborConfigId ospfConfigId); @Nonnull Optional<Layer2Vni> getVniSettings(String hostname, int vni); Optional<Vrf> getVrf(String hostname, String vrfName); static NetworkConfigurations of(Map<String, Configuration> configurations); @Nonnull Optional<Stream<OspfNeighborConfigId>> getOspfNeighborConfigs(
      String hostname, String interfaceName);  }