twitter4j
Class Annotation

java.lang.Object
  extended by twitter4j.Annotation
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<Annotation>

public class Annotation
extends java.lang.Object
implements java.lang.Comparable<Annotation>, java.io.Serializable

A data class representing an Annotation of a Status or a Tweet

Since:
Twitter4J 2.1.4
Author:
Roy Reshef - royreshef at gmail.com
See Also:
Annotations Overview | dev.twitter.com, Serialized Form

Field Summary
private  java.util.Map<java.lang.String,java.lang.String> attributes
           
private static long serialVersionUID
           
private  java.lang.String type
           
 
Constructor Summary
Annotation(twitter4j.internal.org.json.JSONObject jsonObject)
          Construct an Annotation instance from a JSON Object, returned from Twitter API Package visibility only!
Annotation(java.lang.String type)
          Construct an Annotation with a type but no attributes
Annotation(java.lang.String type, java.util.Map<java.lang.String,java.lang.String> attributes)
          Construct an Annotation with a type and attributes
 
Method Summary
 void addAttribute(java.lang.String name, java.lang.String value)
          Adds a single attribute
(package private)  twitter4j.internal.org.json.JSONObject asJSONObject()
          Package visibility only! Converts this to a JSON object according to Twitter's specification
(package private)  java.lang.String asParameterValue()
          Package visibility only!
 Annotation attribute(java.lang.String name, java.lang.String value)
          Adds a single attribute
 Annotation attributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Sets the attributes Ensures the class's property is not null
 int compareTo(Annotation other)
           
 boolean equals(java.lang.Object obj)
           
 java.util.Map<java.lang.String,java.lang.String> getAttributes()
           
 java.lang.String getType()
           
 int hashCode()
           
 boolean isEmpty()
           
 void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
          Sets the attributes Ensures the class's property is not null
 void setType(java.lang.String type)
          Sets the type Ensures the class's property is not null
 java.lang.Integer size()
           
private  java.util.SortedSet<java.lang.String> sortedNames()
           
 java.lang.String toString()
           
 Annotation type(java.lang.String type)
          Sets the type Ensures the class's property is not null
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

type

private java.lang.String type

attributes

private java.util.Map<java.lang.String,java.lang.String> attributes
Constructor Detail

Annotation

public Annotation(java.lang.String type)
Construct an Annotation with a type but no attributes

Parameters:
type - - the type

Annotation

public Annotation(java.lang.String type,
                  java.util.Map<java.lang.String,java.lang.String> attributes)
Construct an Annotation with a type and attributes

Parameters:
type -
attributes -

Annotation

Annotation(twitter4j.internal.org.json.JSONObject jsonObject)
Construct an Annotation instance from a JSON Object, returned from Twitter API Package visibility only!

Parameters:
jsonObject - - the JSON Object
Method Detail

getType

public java.lang.String getType()
Returns:
the type

setType

public void setType(java.lang.String type)
Sets the type Ensures the class's property is not null

Parameters:
type - - the type

type

public Annotation type(java.lang.String type)
Sets the type Ensures the class's property is not null

Parameters:
type - - the type
Returns:
this (for coding convenience)

getAttributes

public java.util.Map<java.lang.String,java.lang.String> getAttributes()
Returns:
the attributes

setAttributes

public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Sets the attributes Ensures the class's property is not null

Parameters:
attributes - - the attributes

attributes

public Annotation attributes(java.util.Map<java.lang.String,java.lang.String> attributes)
Sets the attributes Ensures the class's property is not null

Parameters:
attributes - - the attributes
Returns:
this (for coding convenience)

addAttribute

public void addAttribute(java.lang.String name,
                         java.lang.String value)
Adds a single attribute

Parameters:
name - - the attribute name
value - - the attribute value

attribute

public Annotation attribute(java.lang.String name,
                            java.lang.String value)
Adds a single attribute

Parameters:
name - - the attribute name
value - - the attribute value
Returns:
this (for coding convenience)

isEmpty

public boolean isEmpty()
Returns:
true if the attributes are empty, false otherwise

size

public java.lang.Integer size()
Returns:
true the number of attributes

asParameterValue

java.lang.String asParameterValue()
Package visibility only!

Returns:
the JSON String representation of this

asJSONObject

twitter4j.internal.org.json.JSONObject asJSONObject()
Package visibility only! Converts this to a JSON object according to Twitter's specification

Returns:
the JSON Object

compareTo

public int compareTo(Annotation other)
Specified by:
compareTo in interface java.lang.Comparable<Annotation>

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

sortedNames

private java.util.SortedSet<java.lang.String> sortedNames()
Returns:
a sorted set of the attributes' names