com.netflix.servo.tag
Class BasicTagList

java.lang.Object
  extended by com.netflix.servo.tag.BasicTagList
All Implemented Interfaces:
TagList, java.lang.Iterable<Tag>

public final class BasicTagList
extends java.lang.Object
implements TagList

Immutable tag list.


Field Summary
static TagList EMPTY
          An empty tag list.
 
Constructor Summary
BasicTagList(java.lang.Iterable<Tag> entries)
          Creates a new instance with a fixed set of tags.
 
Method Summary
 java.util.Map<java.lang.String,java.lang.String> asMap()
          Returns a map containing a copy of the tags in this list.
static BasicTagList concat(TagList t1, Tag... t2)
          Returns a tag list containing the union of t1 and t2.
static BasicTagList concat(TagList t1, TagList t2)
          Returns a tag list containing the union of t1 and t2.
 boolean containsKey(java.lang.String key)
          Returns true if this list has a tag with the given key.
 BasicTagList copy(java.lang.String key, java.lang.String value)
          Returns a new tag list with an additional tag.
 BasicTagList copy(TagList tags)
          Returns a new tag list with additional tags from tags.
static BasicTagList copyOf(java.lang.Iterable<java.lang.String> tags)
          Returns a tag list that has a copy of tags.
static BasicTagList copyOf(java.util.Map<java.lang.String,java.lang.String> tags)
          Returns a tag list that has a copy of tags.
static BasicTagList copyOf(java.lang.String... tags)
          Deprecated. Use of(String...) with separate key, values instead.
static BasicTagList copyOf(Tag... tags)
          Deprecated. Use of(Tag...)
 boolean equals(java.lang.Object obj)
          
 Tag getTag(java.lang.String key)
          Returns the tag matching a given key or null if not match is found.
 java.lang.String getValue(java.lang.String key)
          Returns the value matching a given key or null if not match is found.
 int hashCode()
          
 boolean isEmpty()
          Returns true if this list is emtpy.
 java.util.Iterator<Tag> iterator()
          
static BasicTagList of(java.lang.String... tags)
          Returns a tag list from the list of key values passed.
static BasicTagList of(Tag... tags)
          Returns a tag list from the tags.
 int size()
          Returns the number of tags in this list.
 java.lang.String toString()
          
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final TagList EMPTY
An empty tag list.

Constructor Detail

BasicTagList

public BasicTagList(java.lang.Iterable<Tag> entries)
Creates a new instance with a fixed set of tags.

Parameters:
entries - entries to include in this tag list
Method Detail

getTag

public Tag getTag(java.lang.String key)
Returns the tag matching a given key or null if not match is found.

Specified by:
getTag in interface TagList

getValue

public java.lang.String getValue(java.lang.String key)
Returns the value matching a given key or null if not match is found.

Specified by:
getValue in interface TagList

containsKey

public boolean containsKey(java.lang.String key)
Returns true if this list has a tag with the given key.

Specified by:
containsKey in interface TagList

isEmpty

public boolean isEmpty()
Returns true if this list is emtpy.

Specified by:
isEmpty in interface TagList

size

public int size()
Returns the number of tags in this list.

Specified by:
size in interface TagList

iterator

public java.util.Iterator<Tag> iterator()

Specified by:
iterator in interface TagList
Specified by:
iterator in interface java.lang.Iterable<Tag>

asMap

public java.util.Map<java.lang.String,java.lang.String> asMap()
Returns a map containing a copy of the tags in this list.

Specified by:
asMap in interface TagList

copy

public BasicTagList copy(TagList tags)
Returns a new tag list with additional tags from tags. If there is a conflict with tag keys the tag from tags will be used.


copy

public BasicTagList copy(java.lang.String key,
                         java.lang.String value)
Returns a new tag list with an additional tag. If key is already present in this tag list the value will be overwritten with value.


equals

public boolean equals(java.lang.Object obj)

Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object

concat

public static BasicTagList concat(TagList t1,
                                  TagList t2)
Returns a tag list containing the union of t1 and t2. If there is a conflict with tag keys, the tag from t2 will be used.


concat

public static BasicTagList concat(TagList t1,
                                  Tag... t2)
Returns a tag list containing the union of t1 and t2. If there is a conflict with tag keys, the tag from t2 will be used.


of

public static BasicTagList of(java.lang.String... tags)
Returns a tag list from the list of key values passed. Example: BasicTagList tagList = BasicTagList.of("id", "someId", "class", "someClass");


of

public static BasicTagList of(Tag... tags)
Returns a tag list from the tags.


copyOf

@Deprecated
public static BasicTagList copyOf(Tag... tags)
Deprecated. Use of(Tag...)

Returns a tag list that has a copy of tags.


copyOf

@Deprecated
public static BasicTagList copyOf(java.lang.String... tags)
Deprecated. Use of(String...) with separate key, values instead.

Returns a tag list that has a copy of tags. Each tag value is expected to be a string parseable using BasicTag.parseTag(java.lang.String).


copyOf

public static BasicTagList copyOf(java.lang.Iterable<java.lang.String> tags)
Returns a tag list that has a copy of tags. Each tag value is expected to be a string parseable using BasicTag.parseTag(java.lang.String).


copyOf

public static BasicTagList copyOf(java.util.Map<java.lang.String,java.lang.String> tags)
Returns a tag list that has a copy of tags.