The check implied by Optional.get() differs only by the exception thrown
-- and VerifyException is more appropriate. By same token we can
side-step the Optional and use childByArg() instead.
Change-Id: I317577ef635c621be360297a2b5b376edbbbd2d4
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
}
private static Ipv4Prefix extractPrefix(final MapEntryNode ipv4Route) {
- return new Ipv4Prefix((String) ipv4Route.findChildByArg(ROUTE_KEY_PREFIX_LEAF).get().body());
+ return new Ipv4Prefix((String) ipv4Route.getChildByArg(ROUTE_KEY_PREFIX_LEAF).body());
}
private static PathId extractPathId(final MapEntryNode ipv4Route) {
- return ipv4Route.findChildByArg(ROUTE_KEY_PATHID_LEAF)
- .map(dataContainerChild -> new PathId((Uint32) dataContainerChild.body()))
- .orElse(null);
+ final var pathId = ipv4Route.childByArg(ROUTE_KEY_PATHID_LEAF);
+ return pathId == null ? null : new PathId((Uint32) pathId.body());
}
public void close() {