Source class abstract

Abstract base class for all reflection metadata that can be annotated.

Provides common functionality for working with annotations and protection domains across all reflectable elements (classes, methods, fields, etc.).

{@template source_metadata_features}

Key Features

  • Annotation discovery and filtering by type
  • Protection domain integration
  • Type-safe annotation access
  • Permission checking

Implementations

Typically implemented by:

  • ClassMetadata for class-level annotations
  • MethodMetadata for method annotations
  • FieldMetadata for field annotations
  • ParameterMetadata for parameter annotations

Example Usage

// Get class metadata
final classMeta = reflector.getClass('MyClass');

// Check for specific annotation
if (classMeta.hasDirectAnnotation<JsonSerializable>()) {
  // Get annotation instance
  final jsonAnn = classMeta.getDirectAnnotation<JsonSerializable>();
  print('Uses JSON serialization');
}

// Get all controller annotations
final controllers = classMeta.getDirectAnnotations<RestController>();

{@endtemplate}

Inheritance
Implementers

Constructors

Source()
Abstract base class for all reflection metadata that can be annotated.
const

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

annotationMatches<A>(Annotation annotation) bool
checkAccess(String operation, DomainPermission permission) → void
Verifies access permissions before performing sensitive operations.
inherited
getAllDirectAnnotations() List<Annotation>
Gets all annotations applied to this element.
getDeclaration() Declaration
Gets the type declaration metadata for this class.
getDirectAnnotation<A>() → A?
Gets a single annotation by type, if present.
getDirectAnnotations<A>() List<A>
Gets all annotations of a specific type.
getName() String
Gets the declared name of the source.
getProtectionDomain() ProtectionDomain
Gets the protection domain governing access to this element.
inherited
getSignature() String
Gets the executable signature as a string.
hasDirectAnnotation<A>() bool
Checks if this element has a specific annotation.
isPublic() bool
Checks if this element is public.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited