Package com.yahoo.document.annotation
Class AnnotationType
- java.lang.Object
-
- com.yahoo.document.annotation.AnnotationType
-
- All Implemented Interfaces:
java.lang.Comparable<AnnotationType>
public class AnnotationType extends java.lang.Object implements java.lang.Comparable<AnnotationType>
An AnnotationType describes a certain type of annotations; they are generally distinguished by a name, an id, and an optional data type.If an AnnotationType has a
DataType
, this means thatAnnotation
s of that type are allowed to have aFieldValue
of the givenDataType
as an optional payload.- Author:
- Einar M R Rosenvinge
-
-
Constructor Summary
Constructors Constructor Description AnnotationType(java.lang.String name)
Creates a new annotation type that cannot have values (hence no data type).AnnotationType(java.lang.String name, int id)
Creates a new annotation type, with the specified ID. WARNING! Only to be used by configuration system, do not use!!AnnotationType(java.lang.String name, DataType dataType)
Creates a new annotation type that can have values of the specified type.AnnotationType(java.lang.String name, DataType dataType, int id)
Creates a new annotation type that can have values of the specified type.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(AnnotationType annotationType)
boolean
equals(java.lang.Object o)
DataType
getDataType()
Returns the data type of this annotation, if any.int
getId()
Returns the ID of this annotation.java.util.Collection<AnnotationType>
getInheritedTypes()
java.lang.String
getName()
Returns the name of this annotation.int
hashCode()
void
inherit(AnnotationType type)
WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.boolean
inherits(AnnotationType type)
boolean
isValueCompatible(Annotation structValue)
void
setDataType(DataType dataType)
Sets the data type of this annotation. WARNING! Only to be used by configuration system, do not use!!java.lang.String
toString()
-
-
-
Constructor Detail
-
AnnotationType
public AnnotationType(java.lang.String name)
Creates a new annotation type that cannot have values (hence no data type).- Parameters:
name
- the name of the new annotation type
-
AnnotationType
public AnnotationType(java.lang.String name, DataType dataType)
Creates a new annotation type that can have values of the specified type.- Parameters:
name
- the name of the new annotation typedataType
- the data type of the annotation value
-
AnnotationType
public AnnotationType(java.lang.String name, DataType dataType, int id)
Creates a new annotation type that can have values of the specified type.- Parameters:
name
- the name of the new annotation typedataType
- the data type of the annotation valueid
- the ID of the new annotation type
-
AnnotationType
public AnnotationType(java.lang.String name, int id)
Creates a new annotation type, with the specified ID. WARNING! Only to be used by configuration system, do not use!!- Parameters:
name
- the name of the new annotation typeid
- the ID of the new annotation type
-
-
Method Detail
-
getName
public java.lang.String getName()
Returns the name of this annotation.- Returns:
- the name of this annotation.
-
getDataType
public DataType getDataType()
Returns the data type of this annotation, if any.- Returns:
- the data type of this annotation, or null.
-
setDataType
public void setDataType(DataType dataType)
Sets the data type of this annotation. WARNING! Only to be used by configuration system, do not use!!- Parameters:
dataType
- the data type of the annotation value
-
getId
public int getId()
Returns the ID of this annotation.- Returns:
- the ID of this annotation.
-
isValueCompatible
public boolean isValueCompatible(Annotation structValue)
-
inherit
public void inherit(AnnotationType type)
WARNING! Only to be used by the configuration system and in unit tests. Not to be used in production code.- Parameters:
type
- the type to inherit from
-
getInheritedTypes
public java.util.Collection<AnnotationType> getInheritedTypes()
-
inherits
public boolean inherits(AnnotationType type)
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
compareTo
public int compareTo(AnnotationType annotationType)
- Specified by:
compareTo
in interfacejava.lang.Comparable<AnnotationType>
-
-