default T visit(Location location) { return location.accept(this); }
/** * Converts {@code loc} to an InterfaceLink location. The function is a no-op if {@code loc} is * already an InterfaceLink location. */ static Location toInterfaceLinkLocation(Location loc) { return loc.accept( new LocationVisitor<Location>() { @Override public Location visitInterfaceLinkLocation(InterfaceLinkLocation interfaceLinkLocation) { return interfaceLinkLocation; } @Override public Location visitInterfaceLocation(InterfaceLocation interfaceLocation) { return new InterfaceLinkLocation( interfaceLocation.getNodeName(), interfaceLocation.getInterfaceName()); } }); } }
private void setSourceLocation(Flow.Builder flowBuilder, Location loc) { loc.accept( new LocationVisitor<Void>() { @Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; } @Override public Void visitInterfaceLocation(@Nonnull InterfaceLocation interfaceLocation) { flowBuilder .setIngressInterface(null) .setIngressNode(interfaceLocation.getNodeName()) .setIngressVrf( interfaceVrf( interfaceLocation.getNodeName(), interfaceLocation.getInterfaceName())); return null; } }); }
private static void setSourceLocation(Builder flowBuilder, Location loc, Configuration c) { loc.accept( new LocationVisitor<Void>() { @Override public Void visitInterfaceLinkLocation( @Nonnull InterfaceLinkLocation interfaceLinkLocation) { flowBuilder .setIngressInterface(interfaceLinkLocation.getInterfaceName()) .setIngressNode(interfaceLinkLocation.getNodeName()) .setIngressVrf(null); return null; } @Override public Void visitInterfaceLocation(@Nonnull InterfaceLocation interfaceLocation) { flowBuilder .setIngressInterface(null) .setIngressNode(interfaceLocation.getNodeName()) .setIngressVrf( c.getAllInterfaces() .get(interfaceLocation.getInterfaceName()) .getVrf() .getName()); return null; } }); } }
@Override public IpSpaceAssignment resolve(Set<Location> locations, SpecifierContext ctxt) { IpSpaceLocationVisitor ipSpaceLocationVisitor = new IpSpaceLocationVisitor(ctxt); IpSpaceAssignment.Builder builder = IpSpaceAssignment.builder(); locations.forEach( location -> builder.assign(location, location.accept(ipSpaceLocationVisitor))); return builder.build(); } }
location -> ipSpacePerLocation.merge( location.accept(toIngressLocation), entry.getIpSpace(), ((ipSpace1, ipSpace2) -> AclIpSpace.union(ipSpace1, ipSpace2)))));