public final class

ElementKey

extends MetadataKey<D>
java.lang.Object
   ↳ com.google.gdata.model.MetadataKey<D>
     ↳ com.google.gdata.model.ElementKey<D, E extends com.google.gdata.model.Element>

Class Overview

A key referring to a particular element. Holds the ID of the element and the expected datatype and element type. Element keys support value-based equality, natural ordering, and matching.

  • An element key is equals(Object) to another element key if their IDs are equivalent or both null, and their datatypes, and element types are the same.
  • An element key's natural ordering is based first on the name, then on the element type, and finally on the data type.
  • An element key matches(MetadataKey) another element key if the ID is a match for the ID of the other key, and the datatype and element type are both assignable from the other key's datatype and element type.

Summary

Fields
final Class<? extends E extends Element> elementType
[Expand]
Inherited Fields
From class com.google.gdata.model.MetadataKey
Public Methods
int compareTo(MetadataKey<?> other)
Compares first on ID, then on element type, then on datatype.
boolean equals(Object obj)
Class<? extends E> getElementType()
Returns the element type of the element.
int hashCode()
boolean matches(MetadataKey<?> other)
Returns true if this key is a match for the given key.
static <T, V extends Element> ElementKey<T, V> of(QName id, Class<? extends T> datatype, Class<? extends V> elementType)
Construct an element key with the given id, datatype, and element type.
static <V extends Element> ElementKey<Void, V> of(QName id, Class<? extends V> elementType)
Construct an element key with the given id and element type, but with a Void datatype.
static ElementKey<String, Element> of(QName id)
Return a default element key using a string datatype and Element as the element type.
String toString()
[Expand]
Inherited Methods
From class com.google.gdata.model.MetadataKey
From class java.lang.Object
From interface java.lang.Comparable

Fields

final Class<? extends E extends Element> elementType

Public Methods

public int compareTo (MetadataKey<?> other)

Compares first on ID, then on element type, then on datatype.

Parameters
other

public boolean equals (Object obj)

Parameters
obj

public Class<? extends E> getElementType ()

Returns the element type of the element.

public int hashCode ()

public boolean matches (MetadataKey<?> other)

Returns true if this key is a match for the given key. This key is a match for the other key if the other key is also an element key and if the ID, datatype, and element types all match.

Parameters
other

public static ElementKey<T, V> of (QName id, Class<? extends T> datatype, Class<? extends V> elementType)

Construct an element key with the given id, datatype, and element type. This is used for elements that contain text content.

The elementType must not be null. A null id is only valid for element types that are a subclass of Element, and are used as a key referring to all instances of that element type.

Parameters
id
datatype
elementType

public static ElementKey<Void, V> of (QName id, Class<? extends V> elementType)

Construct an element key with the given id and element type, but with a Void datatype. This is used for elements without text content.

The elementType must not be null. A null id is only valid for element types that are a subclass of Element, and are used as a key referring to all instances of that element type.

Parameters
id
elementType

public static ElementKey<String, Element> of (QName id)

Return a default element key using a string datatype and Element as the element type. The id must not be null.

Parameters
id

public String toString ()