@Test public void testBgpRoute() { SetNextHop expr = new SetNextHop(new IpNextHop(Collections.singletonList(Ip.ZERO))); Bgpv4Route.Builder builder = Bgpv4Route.builder(); expr.execute(Environment.builder(_c).setOutputRoute(builder).build()); assertThat(builder.getNextHopIp(), equalTo(Ip.ZERO)); }
@Override public Result execute(Environment environment) { Result result = new Result(); if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) { return result; } if (_expr.getDiscard()) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setDiscard(true); } Ip nextHop = _expr.getNextHopIp(environment); if (nextHop == null) { return result; } environment.getOutputRoute().setNextHopIp(nextHop); return result; }
SetNextHop extends Statement { @Override public Result execute(Environment environment) { Result result = new Result(); if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) { return result; } if (_expr.getDiscard()) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setDiscard(true); } Ip nextHop = _expr.getNextHopIp(environment); if (nextHop == null) { return result; } environment.getOutputRoute().setNextHopIp(nextHop); return result; } }
SetNextHop extends Statement { @Override public Result execute(Environment environment) { Result result = new Result(); if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) { return result; } if (_expr.getDiscard()) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setDiscard(true); } Ip nextHop = _expr.getNextHopIp(environment); if (nextHop == null) { return result; } environment.getOutputRoute().setNextHopIp(nextHop); return result; } SetNextHop(NextHopExpr expr); }
SetNextHop extends Statement { @Override public Result execute(Environment environment) { Result result = new Result(); if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) { return result; } if (_expr.getDiscard()) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setDiscard(true); } Ip nextHop = _expr.getNextHopIp(environment); if (nextHop == null) { return result; } environment.getOutputRoute().setNextHopIp(nextHop); return result; } SetNextHop(NextHopExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) @Nonnull NextHopExpr getExpr(); @Override boolean equals(Object o); @Override int hashCode(); }
SetNextHop extends Statement { @Override public Result execute(Environment environment) { Result result = new Result(); if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) { return result; } if (_expr.getDiscard()) { BgpRoute.Builder<?, ?> bgpRouteBuilder = (BgpRoute.Builder<?, ?>) environment.getOutputRoute(); bgpRouteBuilder.setDiscard(true); } Ip nextHop = _expr.getNextHopIp(environment); if (nextHop == null) { return result; } environment.getOutputRoute().setNextHopIp(nextHop); return result; } SetNextHop(NextHopExpr expr); @Override T accept(StatementVisitor<T, U> visitor, U arg); @Override Result execute(Environment environment); @JsonProperty(PROP_EXPR) @Nonnull NextHopExpr getExpr(); @Override boolean equals(Object o); @Override int hashCode();  }