Committed by
Gerrit Code Review
Add API to look up interface by name
Change-Id: I03fcae92e83f5b804bca21a105d4d1ee8295f2ad
Showing
2 changed files
with
20 additions
and
0 deletions
... | @@ -39,6 +39,15 @@ public interface InterfaceService | ... | @@ -39,6 +39,15 @@ public interface InterfaceService |
39 | Set<Interface> getInterfaces(); | 39 | Set<Interface> getInterfaces(); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | + * Returns the interface with the given name. | ||
43 | + * | ||
44 | + * @param connectPoint connect point of the interface | ||
45 | + * @param name name of the interface | ||
46 | + * @return interface if it exists, otherwise null | ||
47 | + */ | ||
48 | + Interface getInterfaceByName(ConnectPoint connectPoint, String name); | ||
49 | + | ||
50 | + /** | ||
42 | * Returns the set of interfaces configured on the given port. | 51 | * Returns the set of interfaces configured on the given port. |
43 | * | 52 | * |
44 | * @param port connect point | 53 | * @param port connect point | ... | ... |
... | @@ -102,6 +102,17 @@ public class InterfaceManager extends ListenerRegistry<InterfaceEvent, Interface | ... | @@ -102,6 +102,17 @@ public class InterfaceManager extends ListenerRegistry<InterfaceEvent, Interface |
102 | } | 102 | } |
103 | 103 | ||
104 | @Override | 104 | @Override |
105 | + public Interface getInterfaceByName(ConnectPoint connectPoint, String name) { | ||
106 | + Optional<Interface> intf = | ||
107 | + interfaces.getOrDefault(connectPoint, Collections.emptySet()) | ||
108 | + .stream() | ||
109 | + .filter(i -> i.name().equals(name)) | ||
110 | + .findAny(); | ||
111 | + | ||
112 | + return intf.isPresent() ? intf.get() : null; | ||
113 | + } | ||
114 | + | ||
115 | + @Override | ||
105 | public Set<Interface> getInterfacesByPort(ConnectPoint port) { | 116 | public Set<Interface> getInterfacesByPort(ConnectPoint port) { |
106 | Set<Interface> intfs = interfaces.get(port); | 117 | Set<Interface> intfs = interfaces.get(port); |
107 | if (intfs == null) { | 118 | if (intfs == null) { | ... | ... |
-
Please register or login to post a comment