org.linkedin.glu.utils.tags
Class TaggeableSetImpl

java.lang.Object
  extended by org.linkedin.glu.utils.tags.TaggeableSetImpl
All Implemented Interfaces:
ReadOnlyTaggeable, Taggeable, WriteOnlyTaggeable
Direct Known Subclasses:
TaggeableHashSetImpl, TaggeableTreeSetImpl

public abstract class TaggeableSetImpl
extends java.lang.Object
implements Taggeable


Field Summary
 
Fields inherited from interface org.linkedin.glu.utils.tags.ReadOnlyTaggeable
EMPTY
 
Constructor Summary
TaggeableSetImpl()
          Constructor
TaggeableSetImpl(java.util.Collection<java.lang.String> tags)
          Constructor
 
Method Summary
 boolean addTag(java.lang.String tag)
          Adds a tag.
 java.util.Set<java.lang.String> addTags(java.util.Collection<java.lang.String> tags)
          Adds all the tags.
protected abstract  java.util.Set<java.lang.String> createEmptySet()
           
protected abstract  java.util.Set<java.lang.String> createSet(java.util.Collection<java.lang.String> tags)
           
 boolean equals(java.lang.Object o)
           
 java.util.Set<java.lang.String> getCommonTags(java.util.Collection<java.lang.String> tags)
           
 java.util.Set<java.lang.String> getMissingTags(java.util.Collection<java.lang.String> tags)
           
 java.util.Set<java.lang.String> getTags()
           
 int getTagsCount()
           
 boolean hasAllTags(java.util.Collection<java.lang.String> tags)
           
 boolean hasAnyTag(java.util.Collection<java.lang.String> tags)
           
 int hashCode()
           
 boolean hasTag(java.lang.String tag)
           
 boolean hasTags()
           
 boolean removeTag(java.lang.String tag)
          Removes the provided tag.
 java.util.Set<java.lang.String> removeTags(java.util.Collection<java.lang.String> tags)
          Removes all the tags.
 void setTags(java.util.Collection<java.lang.String> tags)
          Allow you to set the exact set of tags you want.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaggeableSetImpl

public TaggeableSetImpl()
Constructor


TaggeableSetImpl

public TaggeableSetImpl(java.util.Collection<java.lang.String> tags)
Constructor

Method Detail

createEmptySet

protected abstract java.util.Set<java.lang.String> createEmptySet()

createSet

protected abstract java.util.Set<java.lang.String> createSet(java.util.Collection<java.lang.String> tags)

getTagsCount

public int getTagsCount()
Specified by:
getTagsCount in interface ReadOnlyTaggeable
Returns:
the number of tags

hasTags

public boolean hasTags()
Specified by:
hasTags in interface ReadOnlyTaggeable
Returns:
true if there are no tags

getTags

public java.util.Set<java.lang.String> getTags()
Specified by:
getTags in interface ReadOnlyTaggeable
Returns:
the set of all tags

hasTag

public boolean hasTag(java.lang.String tag)
Specified by:
hasTag in interface ReadOnlyTaggeable
Returns:
true if the given tag is present

hasAllTags

public boolean hasAllTags(java.util.Collection<java.lang.String> tags)
Specified by:
hasAllTags in interface ReadOnlyTaggeable
Returns:
true if the given tags are present (all of them)

hasAnyTag

public boolean hasAnyTag(java.util.Collection<java.lang.String> tags)
Specified by:
hasAnyTag in interface ReadOnlyTaggeable
Returns:
true if at least one of them is present

getCommonTags

public java.util.Set<java.lang.String> getCommonTags(java.util.Collection<java.lang.String> tags)
Specified by:
getCommonTags in interface ReadOnlyTaggeable
Returns:
a subset of the provided tags containing all the tags that are present in this object. (intersection)

getMissingTags

public java.util.Set<java.lang.String> getMissingTags(java.util.Collection<java.lang.String> tags)
Specified by:
getMissingTags in interface ReadOnlyTaggeable
Returns:
a subset of the provided tags containing all the tags that are not present in this object. (difference)

addTag

public boolean addTag(java.lang.String tag)
Description copied from interface: WriteOnlyTaggeable
Adds a tag.

Specified by:
addTag in interface WriteOnlyTaggeable
Returns:
true if the tag which was added was a new tag, otherwise false

addTags

public java.util.Set<java.lang.String> addTags(java.util.Collection<java.lang.String> tags)
Description copied from interface: WriteOnlyTaggeable
Adds all the tags.

Specified by:
addTags in interface WriteOnlyTaggeable
Returns:
the set of tags that were added (empty set if they were all already present)

removeTag

public boolean removeTag(java.lang.String tag)
Description copied from interface: WriteOnlyTaggeable
Removes the provided tag.

Specified by:
removeTag in interface WriteOnlyTaggeable
Returns:
true if the tag was removed or false if the tag was not present in the first place

removeTags

public java.util.Set<java.lang.String> removeTags(java.util.Collection<java.lang.String> tags)
Description copied from interface: WriteOnlyTaggeable
Removes all the tags.

Specified by:
removeTags in interface WriteOnlyTaggeable
Returns:
the set of tags that were not present (empty set if they were all already present)

setTags

public void setTags(java.util.Collection<java.lang.String> tags)
Description copied from interface: WriteOnlyTaggeable
Allow you to set the exact set of tags you want. Equivalent to calling (in an atomic fashion)
 removeTags(getTags())
 addTags(tags)
 

Specified by:
setTags in interface WriteOnlyTaggeable
Parameters:
tags - tags to set

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object