@Override public LocationSpecifier buildLocationSpecifier(Pattern input) { return new DescriptionRegexInterfaceLocationSpecifier(input); } }
public static LocationSpecifier from(@Nonnull InterfacesSpecifier ingressInterfaces) { switch (ingressInterfaces.getType()) { case DESC: return new DescriptionRegexInterfaceLocationSpecifier(ingressInterfaces.getRegex()); case NAME: return new NameRegexInterfaceLocationSpecifier(ingressInterfaces.getRegex()); case VRF: return new VrfNameRegexInterfaceLocationSpecifier(ingressInterfaces.getRegex()); default: throw new BatfishException( "Unexcepted InterfacesSpecifier type: " + ingressInterfaces.getType()); } }
@Test public void testDescriptionRegexInterfaceLocationSpecifierFactory() { assertThat( LocationSpecifierFactory.load( new DescriptionRegexInterfaceLocationSpecifierFactory().getName()), instanceOf(DescriptionRegexInterfaceLocationSpecifierFactory.class)); assertThat( new DescriptionRegexInterfaceLocationSpecifierFactory().getName(), equalTo(DescriptionRegexInterfaceLocationSpecifierFactory.NAME)); assertThat( new DescriptionRegexInterfaceLocationSpecifierFactory().buildLocationSpecifier(PATTERN_SRC), equalTo(new DescriptionRegexInterfaceLocationSpecifier(PATTERN))); }