Spec<T> class abstract

A Jetleaf definition describing how a pod should be instantiated, configured, and managed inside the container.

A Spec acts as a fluent builder for pod registration. It allows chaining configuration methods for scope, lifecycle, dependencies, naming, and autowiring.

When to use

Use a Spec whenever you register a pod inside a Registry. It provides a structured, declarative way to define pod behaviors and their container interactions.

Example

registry.registerPod(MyService.classType, customizer: (spec) {
  spec
    .namedAs('myService')
    .withScope(ScopeType.singleton)
    .describedAs('Provides business logic services')
    .suppliedBy((ctx) => MyService(ctx.get(Dependency.classType)));
});

Fluent Chaining

All methods return the same Spec<T> instance, allowing chained invocations.

Annotations
  • @Generic.new(Spec)

Constructors

Spec({required Class type})
A Jetleaf definition describing how a pod should be instantiated, configured, and managed inside the container.

Properties

annotatedClasses List<Class>
The list of annotation classes which the type of this pod definition is annotated with.
finalinherited
annotations List<Annotation>
The complete list of annotations discovered on the class and its meta-annotations.
finalinherited
autowireCandidate ↔ AutowireCandidateDescriptor
Defines whether this pod is eligible for autowiring.
getter/setter pairinherited
dependencyCheck ↔ DependencyCheck
Defines the dependency validation strategy.
getter/setter pairinherited
dependsOn List<DependencyDesign>
Other dependencies that this pod depends on.
getter/setter pairinherited
description String?
A description of the pod.
getter/setter pairinherited
design ↔ DesignDescriptor
Defines the design role of the pod.
getter/setter pairinherited
executableArgumentValues ↔ ConstructorArgumentValues
Arguments to be passed to the pod’s constructor.
getter/setter pairinherited
factoryMethod ↔ FactoryMethodDesign
The factory method used to create this pod.
getter/setter pairinherited
hasBeforeInstantiationResolved bool
Whether this pod has been resolved before instantiation.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
isPodProvider bool
Whether this pod is a provider of other pods.
getter/setter pairinherited
lifecycle ↔ LifecycleDesign
Defines the lifecycle behavior of the pod.
getter/setter pairinherited
name String
The unique name of the pod (component).
getter/setter pairinherited
preferredConstructors List<Constructor>
List of preferred constructors for autowiring.
finalinherited
propertyValues ↔ MutablePropertyValues
Mutable property values assigned to this pod.
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scope ↔ ScopeDesign
Defines the scope of the pod.
getter/setter pairinherited
type ↔ Class
The Class type that this pod represents.
getter/setter pairinherited

Methods

addConstructorArguments(ArgumentValue argument) Spec<T>
Adds a constructor argument for pod instantiation.
addPropertyValue(PropertyValue value) Spec<T>
Adds a property value to this pod definition.
asAutowireCandidate(AutowireMode mode) Spec<T>
Declares this pod as an autowire candidate with the given mode.
asPodProvider() Spec<T>
Marks this spec as a pod provider (i.e., a factory for other pods).
clone() → PodDefinition
Creates and returns a deep clone of this pod definition.
inherited
createdBy(String factoryClass, String methodName) Spec<T>
Configures a factory method for creating this pod.
dependingOn(List<DependencyDesign> dependencies) Spec<T>
Declares dependencies required for this pod.
describedAs(String description) Spec<T>
Adds a human-readable description to this pod spec.
This can be useful for debugging, logging, or documentation purposes.
designedWithLifecycle({bool lazy = false, List<String> initMethods = const [], List<String> destroyMethods = const [], bool enforceInitMethod = false, bool enforceDestroyMethod = false}) Spec<T>
Configures lifecycle design for the pod.
equalizedProperties() List<Object?>
Mixin-style contract for value-based equality, hashCode, and toString.
inherited
expressedWith(PodExpression<Object> expression) Spec<T>
Configures the pod using a custom expression.
getAnnotation<A>() → A?
Returns the annotation of type A, if present.
inherited
getAnnotations<A>() List<A>
Returns a list of annotations of type A.
inherited
hasAnnotation<A>() bool
Returns true if this definition has an annotation of type A.
inherited
hasConstructorArgumentValues() bool
Returns whether this pod definition contains any constructor argument values.
inherited
hasPreferredConstructors() bool
Returns whether this pod definition has any preferred constructors.
inherited
hasPropertyValues() bool
Returns whether this pod definition contains any property values.
inherited
isAbstractAndNoFactory() bool
Returns true if this definition is non-instantiable.
inherited
namedAs(String name) Spec<T>
Assigns a logical name to this pod spec.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
suppliedBy(T supplier(SpecContext context)) Spec<T>
Supplies a pod instance using a supplier function.
target(Class<T> type) Spec<T>
Targets this spec towards a specific type.
toString() String
A string representation of this object.
inherited
toStringOptions() → ToStringOptions
inherited
withAutowire(AutowireCandidateDescriptor descriptor) Spec<T>
Provides a descriptor describing autowiring rules for this pod.
withDesign(DesignDescriptor design) Spec<T>
Associates a design descriptor with this pod.
A design encapsulates structural or semantic metadata about the pod.
withDesignRole(DesignRole role, {bool isPrimary = false}) Spec<T>
Assigns a design role to this pod, with an option to mark it as isPrimary for autowiring resolution.
withFactory(FactoryMethodDesign descriptor) Spec<T>
Defines this pod using a factory descriptor.
withLifecycle(LifecycleDesign lifecycle) Spec<T>
Attaches a lifecycle lifecycle definition to this pod.
withScope(ScopeType type) Spec<T>
Defines the type of scope this pod belongs to (e.g., singleton, prototype).

Operators

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