Constraint { @SuppressWarnings("DuplicateStringLiteralInspection") public static Constraint parse(String input) throws IllegalArgumentException { if (!CONSTRAINT_REGEX.test(input)) { throw new IllegalArgumentException("Invalid constraint: " + input); } MatchResult result = CONSTRAINT_REGEX.exec(input); if (result.getGroupCount() != 5) { throw new IllegalArgumentException("Invalid constraint: " + input); } return new Constraint(AddressTemplate.of(result.getGroup(2)), result.getGroup(4), Target.parse(result.getGroup(3)), Permission.valueOf(result.getGroup(1).toUpperCase())); } private  Constraint(AddressTemplate template, String name, Target target, Permission permission); static Constraint executable(AddressTemplate template, String operation); static Constraint writable(AddressTemplate template, String attribute); @SuppressWarnings("DuplicateStringLiteralInspection") static Constraint parse(String input); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); String data(); AddressTemplate getTemplate(); Target getTarget(); String getName(); Permission getPermission();  }
@Test public void parse() { assertEquals(ex, Constraint.parse(ENGAGE_DATA)); assertEquals(wr, Constraint.parse(NCC_DATA)); }
@Test(expected = IllegalArgumentException.class) public void parseNull() { Constraint.parse(null); }
@Test(expected = IllegalArgumentException.class) public void parseEmpty() { Constraint.parse(""); }
@Test(expected = IllegalArgumentException.class) public void parseBlank() { Constraint.parse(" "); }
@Test(expected = IllegalArgumentException.class) public void parseIllegal() { Constraint.parse("not a constraint"); }