class ExplicitAsPathSet extends AsPathSetExpr {

  @Override
  public boolean matches(Environment environment) {
    AsPath asPath = null;
    if (environment.getUseOutputAttributes()
        && environment.getOutputRoute() instanceof BgpRoute.Builder<?, ?>) {
      BgpRoute.Builder<?, ?> bgpRouteBuilder =
          (BgpRoute.Builder<?, ?>) environment.getOutputRoute();
      asPath = bgpRouteBuilder.getAsPath();
    } else if (environment.getReadFromIntermediateBgpAttributes()) {
      asPath = environment.getIntermediateBgpAttributes().getAsPath();
    } else if (environment.getOriginalRoute() instanceof BgpRoute) {
      BgpRoute<?, ?> bgpRoute = (BgpRoute<?, ?>) environment.getOriginalRoute();
      asPath = bgpRoute.getAsPath();
    }
    if (asPath == null) {
      return false;
    }
    // TODO: need to validate regexes against complex AS-Paths that contain sets. For now, regexes
    // will not match against AsPaths for which set components have non-trivial filters.
    String asPathStr = asPath.size() == 0 ? "" : " " + asPath.getAsPathString();
    return _elems.stream()
        .map(AsPathSetElem::regex)
        .anyMatch(r -> Pattern.compile(r).matcher(asPathStr).find());
  }

  public  ExplicitAsPathSet(AsPathSetElem... elems);
  public  ExplicitAsPathSet(Iterable<AsPathSetElem> elems);

}