TagMaskUtils { public static TagMask parse(String text) { TagMask tm = new TagMask(); Matcher m = REPLACE_TAGR2.matcher(text); while (m.find()) { String property = m.group(1); String value = m.group(2).replace('-', ' '); switch (property) { case "number": tm.setNumber(TagMask.Number.fromValue(value)); break; case "gender": tm.setGender(TagMask.Gender.fromValue(value)); break; case "class": tm.setClazz(TagMask.Class.fromValue(value)); break; case "person": tm.setPerson(TagMask.Person.fromValue(value)); break; case "tense": tm.setTense(TagMask.Tense.fromValue(value)); break; case "mood": tm.setMood(TagMask.Mood.fromValue(value)); break; default: throw new IllegalArgumentException("Invalid property: '" + property + "'"); } } return tm; }  static TagMask clone(TagMask tagMask); static TagMask parse(String text); static TagMask createTagMaskFromToken(Token token, String text);  }
@Test public void testParse1() { String s = "number = plural gender=female class = finitive-verb"; TagMask tm = TagMaskUtils.parse(s); assertEquals(TagMask.Number.PLURAL, tm.getNumber()); assertEquals(TagMask.Gender.FEMALE, tm.getGender()); assertEquals(TagMask.Class.FINITIVE_VERB, tm.getClazz()); }
@Test(expected = IllegalArgumentException.class) public void testParse2() { String s = "number = plura"; TagMask tm = TagMaskUtils.parse(s); }
@Test(expected = IllegalArgumentException.class) public void testParse3() { String s = "nuber = plural gender = male"; TagMask tm = TagMaskUtils.parse(s); }