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 Annotations. Annotations are immutable.
Annotations 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 AnnotationDefThe 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 aAnnotationwith the given definition and field values. -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckRep()Check the representation, throw assertion failure if it is violated.final AnnotationDefdef()Returns the definition of the annotation type to which this annotation belongs.final booleanThisAnnotationequalsoif and only ifois a nonnullAnnotationandthisandohave recursively equal definitions and field values, even if they were created by differentAnnotationFactorys.booleanequals(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.inthashCode()Returns the hash code of this annotation as defined onhashCode().toString()Returns a string representation of this annotation, using valid Java syntax.voidFormats 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 aAnnotationwith the given definition and field values. Make sure that the field values obey the rules given ongetFieldValue(java.lang.String)and that subannotations are alsoAnnotations; 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:
Annotationobject. - Array:
Listof 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
ThisAnnotationequalsoif and only ifois a nonnullAnnotationandthisandohave recursively equal definitions and field values, even if they were created by differentAnnotationFactorys. -
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- theAnnotationto 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
-