@Test public void testShouldActivateIfExists() { StaticRoute sr = StaticRoute.builder() .setNetwork(Prefix.parse("1.1.1.0/24")) .setNextHopIp(Ip.parse("1.1.1.1")) .setAdministrativeCost(1) .build(); _rib.mergeRoute(annotateRoute(sr)); assertThat(shouldActivateNextHopIpRoute(sr, _rib), equalTo(true)); }
public static <R extends AbstractRouteDecorator> boolean shouldActivateNextHopIpRoute( @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib) { Set<R> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp()); return matchingRoutes.stream() .map(AbstractRouteDecorator::getAbstractRoute) .anyMatch( routeToNextHop -> !routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)); }
StaticRouteHelper { public static <R extends AbstractRouteDecorator> boolean shouldActivateNextHopIpRoute( @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib) { Set<R> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp()); return matchingRoutes.stream() .map(AbstractRouteDecorator::getAbstractRoute) .anyMatch( routeToNextHop -> !routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)); } }
StaticRouteHelper { public static <R extends AbstractRouteDecorator> boolean shouldActivateNextHopIpRoute( @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib) { Set<R> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp()); return matchingRoutes.stream() .map(AbstractRouteDecorator::getAbstractRoute) .anyMatch( routeToNextHop -> !routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)); }  }
StaticRouteHelper { public static <R extends AbstractRouteDecorator> boolean shouldActivateNextHopIpRoute( @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib) { Set<R> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp()); return matchingRoutes.stream() .map(AbstractRouteDecorator::getAbstractRoute) .anyMatch( routeToNextHop -> !routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)); }  static boolean isInterfaceRoute(StaticRoute route); static boolean isNextVrfRoute(StaticRoute route); static boolean shouldActivateNextHopIpRoute(
      @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib); }
StaticRouteHelper { public static <R extends AbstractRouteDecorator> boolean shouldActivateNextHopIpRoute( @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib) { Set<R> matchingRoutes = rib.longestPrefixMatch(route.getNextHopIp()); return matchingRoutes.stream() .map(AbstractRouteDecorator::getAbstractRoute) .anyMatch( routeToNextHop -> !routeToNextHop.getNetwork().equals(route.getNetwork()) || route.equals(routeToNextHop)); }  static boolean isInterfaceRoute(StaticRoute route); static boolean isNextVrfRoute(StaticRoute route); static boolean shouldActivateNextHopIpRoute(
      @Nonnull StaticRoute route, @Nonnull GenericRib<R> rib);  }