BasicTagList implements TagList { public static BasicTagList of(String... tags) { Preconditions.checkArgument(tags.length % 2 == 0, "tags must be a sequence of key,value pairs"); final SmallTagMap.Builder builder = SmallTagMap.builder(); for (int i = 0; i < tags.length; i += 2) { Tag t = Tags.newTag(tags[i], tags[i + 1]); builder.add(t); } return new BasicTagList(builder.result()); } BasicTagList(SmallTagMap tagMap);  BasicTagList(Iterable<Tag> entries); Tag getTag(String key); String getValue(String key); boolean containsKey(String key); boolean isEmpty(); int size(); Iterator<Tag> iterator(); Map<String, String> asMap(); BasicTagList copy(TagList tags); BasicTagList copy(String key, String value); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString(); static BasicTagList concat(TagList t1, TagList t2); static BasicTagList concat(TagList t1, Tag... t2); static BasicTagList of(String... tags); static BasicTagList of(Tag... tags); @Deprecated static BasicTagList copyOf(Tag... tags); @Deprecated static BasicTagList copyOf(String... tags); static BasicTagList copyOf(Iterable<String> tags); static BasicTagList copyOf(Map<String, String> tags); static final TagList EMPTY; }
@Test public void testOf() throws Exception { BasicTagList expected = BasicTagList.copyOf(mapOf("foo", "bar", "id", "1")); BasicTagList of = BasicTagList.of("foo", "bar", "id", "1"); assertEquals(of, expected); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testOfOddNumber() { BasicTagList.of("foo"); }