Annotation
classin packageklyn.reflection
public class Annotation extends Object:
└ Annotation

Runtime representation of an annotation attached to a reflected type, constructor, method, property, attribute or parameter.

The arguments map stores annotation argument values as source text. This keeps reflection lightweight and avoids guessing a runtime boxed value for enum constants or type references. argumentTypes exposes the token kind recorded by the compiler (String, Int, Identifier, ...).

Example
import klyn.databases.entities

@Entity(tableName="T_Users")
public class User:
pass

annotation = User.type.annotations[0]
assert annotation.name == "Entity"
assert annotation.argument("tableName") == "T_Users"
Properties
Modifier and Type Member Description
public readonly property argumentTypes
argumentTypes as Map<String, String>:
Annotation argument token kinds.
public readonly property arguments
arguments as Map<String, String>:
Annotation arguments as raw source values.
public readonly property name
name as String:
Annotation name.
Inherited Properties
propertyInherited Properties from Object: type
Constructors
Modifier and Type Member Description
public Annotation
Annotation(name as String, arguments as Map<String, String> = null, argumentTypes as Map<String, String> = null):
Builds annotation metadata.
Methods
Modifier and Type Member Description
public argument
argument(name as String, defaultValue as String = "") as String:
Returns an annotation argument value or a default value.
public argumentType
argumentType(name as String, defaultValue as String = "") as String:
Returns an annotation argument token kind or a default value.
public hasArgument
hasArgument(name as String) as Boolean:
Returns true when an argument is explicitly present.
public override toString
toString() as String:
Returns a readable representation of the annotation.
Inherited Methods
methodInherited Methods from Object: deepCopy, fromJson, toDict, toJson, toString, toXml