class SetNextHop extends Statement {

  @Override
  public Result execute(Environment environment) {
    Result result = new Result();
    // Do nothing for a route that is not BGP.
    if (!(environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>)) {
      return result;
    }

    // Handle "discard" next hop, where the route acts as a null route.
    if (_expr.getDiscard()) {
      BgpRoute.Builder<?, ?> bgpRouteBuilder =
          (BgpRoute.Builder<?, ?>) environment.getOutputRoute();
      bgpRouteBuilder.setDiscard(true);
    }

    // Evaluate our next hop expression. If the result is non-null, modify the next hop IP.
    Ip nextHop = _expr.getNextHopIp(environment);
    if (nextHop == null) {
      return result;
    }
    environment.getOutputRoute().setNextHopIp(nextHop);
    return result;
  }

  public  SetNextHop(NextHopExpr expr);

}