Matcher { public boolean matches(String s) { switch (type) { case MatchEqual: return s == value; case MatchNotEqual: return s != value; case MatchRegexp: return matchString(s); case MatchNotRegexp: return !matchString(s); case MatchLiteralOr: return value.indexOf(s) > -1; case MatchNotLiteralOr: return !(value.indexOf(s) > -1); } throw new IllegalStateException("labels.Matcher.Matches: invalid match type"); } Matcher(MatchType type, String name, String value); boolean matches(String s); MatchType getType(); void setType(MatchType type); String getName(); void setName(String name); String getValue(); void setValue(String value);  }
@Test public void testEqualMatches() { Matcher matcher = new Matcher(MatchType.MatchEqual, "k1", "v1"); Assert.assertTrue(matcher.matches("v1")); Assert.assertFalse(matcher.matches("v2")); }