commit | 43d232e038ed3ceb433cfea37fe821edb0adf281 | [log] [tgz] |
---|---|---|
author | Jonathan Hart <jono@onlab.us> | Wed Feb 03 15:34:10 2016 -0800 |
committer | Gerrit Code Review <gerrit@onlab.us> | Wed Feb 03 23:56:12 2016 +0000 |
tree | cdb71de34d557e57bf5570231fad7fc39956f390 | |
parent | fb631b41e0749f88bd48720538e78d198e72a7f5 [diff] |
Add API to look up interface by name Change-Id: I03fcae92e83f5b804bca21a105d4d1ee8295f2ad
diff --git a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java index 38cfdc5..bfe2ec7 100644 --- a/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java +++ b/incubator/api/src/main/java/org/onosproject/incubator/net/intf/InterfaceService.java
@@ -39,6 +39,15 @@ Set<Interface> getInterfaces(); /** + * Returns the interface with the given name. + * + * @param connectPoint connect point of the interface + * @param name name of the interface + * @return interface if it exists, otherwise null + */ + Interface getInterfaceByName(ConnectPoint connectPoint, String name); + + /** * Returns the set of interfaces configured on the given port. * * @param port connect point
diff --git a/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java b/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java index 7edbf25..9da2177 100644 --- a/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java +++ b/incubator/net/src/main/java/org/onosproject/incubator/net/intf/impl/InterfaceManager.java
@@ -102,6 +102,17 @@ } @Override + public Interface getInterfaceByName(ConnectPoint connectPoint, String name) { + Optional<Interface> intf = + interfaces.getOrDefault(connectPoint, Collections.emptySet()) + .stream() + .filter(i -> i.name().equals(name)) + .findAny(); + + return intf.isPresent() ? intf.get() : null; + } + + @Override public Set<Interface> getInterfacesByPort(ConnectPoint port) { Set<Interface> intfs = interfaces.get(port); if (intfs == null) {