@Test(expected = IllegalArgumentException.class) public void testDuplicateTagKeysUsingParse() { Query.parse("metric k1=v1 k1=v2"); }
public static Query parse(String s) { List<String> splits = Arrays.asList(s.split(" ")); String metricName = splits.get(0); List<TagMatcher> matchers = new ArrayList<>(); for (String s2 : splits.subList(1, splits.size())) { Tag tag = Tag.parseTag(s2); if (tag.value.equals("*")) { matchers.add(TagMatcher.wildcardMatch(tag.key, "*")); } else { matchers.add(TagMatcher.exactMatch(tag)); } } return new Query(metricName, matchers); }
Query { public static Query parse(String s) { List<String> splits = Arrays.asList(s.split(" ")); String metricName = splits.get(0); List<TagMatcher> matchers = new ArrayList<>(); for (String s2 : splits.subList(1, splits.size())) { Tag tag = Tag.parseTag(s2); if (tag.value.equals("*")) { matchers.add(TagMatcher.wildcardMatch(tag.key, "*")); } else { matchers.add(TagMatcher.exactMatch(tag)); } } return new Query(metricName, matchers); } }
Query { public static Query parse(String s) { List<String> splits = Arrays.asList(s.split(" ")); String metricName = splits.get(0); List<TagMatcher> matchers = new ArrayList<>(); for (String s2 : splits.subList(1, splits.size())) { Tag tag = Tag.parseTag(s2); if (tag.value.equals("*")) { matchers.add(TagMatcher.wildcardMatch(tag.key, "*")); } else { matchers.add(TagMatcher.exactMatch(tag)); } } return new Query(metricName, matchers); } Query(final String metricName, final List<TagMatcher> tagMatchers); }
Query { public static Query parse(String s) { List<String> splits = Arrays.asList(s.split(" ")); String metricName = splits.get(0); List<TagMatcher> matchers = new ArrayList<>(); for (String s2 : splits.subList(1, splits.size())) { Tag tag = Tag.parseTag(s2); if (tag.value.equals("*")) { matchers.add(TagMatcher.wildcardMatch(tag.key, "*")); } else { matchers.add(TagMatcher.exactMatch(tag)); } } return new Query(metricName, matchers); } Query(final String metricName, final List<TagMatcher> tagMatchers); static Query parse(String s); @Override String toString(); }
Query { public static Query parse(String s) { List<String> splits = Arrays.asList(s.split(" ")); String metricName = splits.get(0); List<TagMatcher> matchers = new ArrayList<>(); for (String s2 : splits.subList(1, splits.size())) { Tag tag = Tag.parseTag(s2); if (tag.value.equals("*")) { matchers.add(TagMatcher.wildcardMatch(tag.key, "*")); } else { matchers.add(TagMatcher.exactMatch(tag)); } } return new Query(metricName, matchers); } Query(final String metricName, final List<TagMatcher> tagMatchers); static Query parse(String s); @Override String toString(); final String metricName; final List<TagMatcher> tagMatchers; }