@Test public void testGetInterface() { Configuration c = new Configuration("foo", ConfigurationFormat.CISCO_IOS); Interface i = Interface.builder().setBandwidth(1e9).setName("eth0").build(); c.getAllInterfaces().put(i.getName(), i); NetworkConfigurations nc = NetworkConfigurations.of(ImmutableMap.of("foo", c)); assertThat(nc.getInterface("bar", "missingIface"), equalTo(Optional.empty())); assertThat(nc.getInterface("foo", "missingIface"), equalTo(Optional.empty())); assertThat(nc.getInterface("foo", "eth0").orElse(null), equalTo(i)); }
@Nonnull public Optional<Interface> getInterface(String hostname, String interfaceName) { return get(hostname).map(Configuration::getAllInterfaces).map(m -> m.get(interfaceName)); }
NetworkConfigurations { @Nonnull public Optional<Interface> getInterface(String hostname, String interfaceName) { return get(hostname).map(Configuration::getAllInterfaces).map(m -> m.get(interfaceName)); } }
NetworkConfigurations { @Nonnull public Optional<Interface> getInterface(String hostname, String interfaceName) { return get(hostname).map(Configuration::getAllInterfaces).map(m -> m.get(interfaceName)); } private  NetworkConfigurations(Map<String, Configuration> configurations); }
NetworkConfigurations { @Nonnull public Optional<Interface> getInterface(String hostname, String interfaceName) { return get(hostname).map(Configuration::getAllInterfaces).map(m -> m.get(interfaceName)); } 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 { @Nonnull public Optional<Interface> getInterface(String hostname, String interfaceName) { return get(hostname).map(Configuration::getAllInterfaces).map(m -> m.get(interfaceName)); } 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);  }