Class Annotation
java.lang.Object
org.checkerframework.afu.scenelib.Annotation
A very simple annotation representation constructed with a map of field names to values. See the
rules for values on
getFieldValue(java.lang.String)
; furthermore, subannotations must be Annotation
s. Annotation
s are immutable.
Annotation
s can be constructed directly or through AnnotationFactory.saf
.
Either way works, but if you construct one directly, you must provide a matching AnnotationDef
yourself.
-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal AnnotationDef
The annotation definition.An unmodifiable copy of the passed map of field values. -
Constructor Summary
ConstructorsConstructorDescriptionAnnotation
(Annotation ja, Map<String, AnnotationDef> adefs) Construct an Annotation for the given java.lang.annotation.Annotation.Annotation
(AnnotationDef def, Map<String, ? extends Object> fields) Constructs aAnnotation
with the given definition and field values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
checkRep()
Check the representation, throw assertion failure if it is violated.final AnnotationDef
def()
Returns the definition of the annotation type to which this annotation belongs.final boolean
ThisAnnotation
equalso
if and only ifo
is a nonnullAnnotation
andthis
ando
have recursively equal definitions and field values, even if they were created by differentAnnotationFactory
s.boolean
equals
(Annotation o) Returns true if this annotation equalso
; a slightly faster variant ofequals(Object)
for when the argument is statically known to be another nonnullAnnotation
.getFieldValue
(String fieldName) Returns the value of the field whose name is given.int
hashCode()
Returns the hash code of this annotation as defined onhashCode()
.toString()
Returns a string representation of this annotation, using valid Java syntax.void
Formats this annotation, using valid Java syntax.
-
Field Details
-
def
The annotation definition. -
fieldValues
An unmodifiable copy of the passed map of field values.
-
-
Constructor Details
-
Annotation
Constructs aAnnotation
with the given definition and field values. Make sure that the field values obey the rules given ongetFieldValue(java.lang.String)
and that subannotations are alsoAnnotation
s; this constructor does not validate the values.- Parameters:
def
- the definition for the constructed annotationfields
- the fields for the constructed annotation
-
Annotation
Construct an Annotation for the given java.lang.annotation.Annotation.- Parameters:
ja
- the java.lang.annotation.Annotation to make an Annotation foradefs
- a cache from which to look up (or insert into) AnnotationDefs
-
-
Method Details
-
checkRep
public void checkRep()Check the representation, throw assertion failure if it is violated. -
getFieldValue
Returns the value of the field whose name is given.Everywhere in the annotation scene library, field values are to be represented as follows:
- Primitive value: wrapper object, such as
Integer
. String
:String
.- Class token: name of the type as a
String
, using the source code notationint[]
for arrays. - Enumeration constant: name of the constant as a
String
. - Subannotation:
Annotation
object. - Array:
List
of elements in the formats defined here. If the element type is unknown (seeAnnotationBuilder.addEmptyArrayField(java.lang.String)
), the array must have zero elements.
- Parameters:
fieldName
- the name of the field whose value to return- Returns:
- the value of the field named
fieldName
- Primitive value: wrapper object, such as
-
def
Returns the definition of the annotation type to which this annotation belongs.- Returns:
- the definition of the annotation type to which this annotation belongs
-
equals
ThisAnnotation
equalso
if and only ifo
is a nonnullAnnotation
andthis
ando
have recursively equal definitions and field values, even if they were created by differentAnnotationFactory
s. -
equals
Returns true if this annotation equalso
; a slightly faster variant ofequals(Object)
for when the argument is statically known to be another nonnullAnnotation
. Subclasses may wish to override this with a hard-coded "&&" of field comparisons to improve performance.- Parameters:
o
- theAnnotation
to compare to this- Returns:
- true if this equals
o
-
hashCode
public int hashCode()Returns the hash code of this annotation as defined onhashCode()
. Subclasses may wish to override this with a hard-coded XOR/addition of fields to improve performance. -
toString
Returns a string representation of this annotation, using valid Java syntax. -
toString
Formats this annotation, using valid Java syntax.- Parameters:
sb
- where to format the annotation to
-