# Pod class

Marks a method as a pod provider, enabling it to participate in the dependency injection (DI) lifecycle of the application.

The method annotated with `@Pod` should return an instance of a component, service, or configuration object. This returned value is automatically registered in the application’s DI container and, by default, managed as a singleton.

## 🔧 How It Works:

- The enclosing class is typically annotated with `@Configuration` or `@AutoConfiguration`.
- During application startup, all methods annotated with `@Pod` are executed, and their return values are registered in the application context.
- These pods are then available for injection into other classes via constructor injection, factory injection, or field injection (depending on the framework).

## 📌 Features:

- Default lifecycle is singleton (created once and reused).
- Supports lazy initialization depending on the framework’s DI engine.
- May support pod naming or conditional creation in extended versions.

## 🧪 Example:

    @Configuration()
    class AppConfig {

      @Pod()
      Logger createLogger() {
        return Logger('AppLogger');
      }

      @Pod()
      HttpClient httpClient(Logger logger) {
        return HttpClient(logger: logger);
      }
    }

In the example above:

- `createLogger()` returns a `Logger` instance registered as a pod.
- `httpClient()` depends on `Logger`, which is automatically injected by the container.

## 🔄 Pod Lifecycle (Simplified):

    - Framework initializes configuration class
    - All @Pod methods are executed
    - Results are cached as singleton pods
    - Pods are injected into constructors or other pods as needed

## 🔥 Advanced Use Cases (Possible Extensions):

- Conditional pods: `@ConditionalOnMissingPod`, `@Profile('dev')`
- Scoped pods: e.g., per request, per session (via `@Scope`)
- Named pods: `@Pod(name: 'myLogger')`

These can be added through optional parameters or decorators in future.

## ❗ Constraints:

- The method must be non-private.
- The method must return a value; `void` is not allowed.
- Must be defined within a class marked with `@Configuration`, `@AutoConfiguration`, etc.
- Cyclic dependencies must be handled explicitly or avoided.

## ✅ Usage Recommendations:

- Prefer pod methods over manual instantiation in app code.
- Keep logic inside pod methods minimal — do initialization but not business logic.
- Group related pods in separate configuration classes for clarity.

## 🧱 Related Annotations:

- `@Configuration` – Marks the containing class as a source of pod definitions.
- `@AutoConfiguration` – Similar but auto-discovered.
- `@Aspect` – Used for cross-cutting concerns.
- `@Inject`, `@Autowired` – For consuming/injecting defined pods.

## 🎯 Target:

Can only be applied to methods:

    @Pod()
    MyService myService() => MyService();

Pod annotation for pod definition methods

This annotation marks a method as a pod producer.

Example Usage:

    @Configuration()
    class DatabaseConfig {
      @Pod()
      @Scope('singleton')
      DatabaseConnection primaryDatabase() {
        return DatabaseConnection(
          url: 'postgresql://localhost:5432/primary',
          maxConnections: 20,
        );
      }

      @Pod('readOnlyDatabase')
      @Scope('prototype')
      DatabaseConnection readOnlyDatabase() {
        return DatabaseConnection(
          url: 'postgresql://localhost:5432/readonly',
          readOnly: true,
        );
      }
    }

Inheritance
  - Object
  - ReflectableAnnotation
  - Pod
Mixed-in types
  - EqualsAndHashCode
Annotations
  - @Target({TargetKind.method})

## Constructors

Pod.new({String? value, AutowireMode autowireMode = AutowireMode.NO, List<String> initMethods = const [], List<String> destroyMethods = const [], bool enforceInitMethods = false, bool enforceDestroyMethods = false})
  Marks a method as a pod provider, enabling it to participate in the dependency injection (DI) lifecycle of the application.
  const

## Properties

annotationType → Type
  Returns the annotation _type of this annotation.
  no setter override
autowireMode → AutowireMode
  Autowire mode for dependency injection.
  final
destroyMethods → List<String>
  List of destruction methods to invoke when the pod is destroyed.
  final
enforceDestroyMethods → bool
  Whether to enforce declared destroy methods.
  final
enforceInitMethods → bool
  Whether to enforce declared init methods.
  final
hashCode → int
  The hash code for this object.
  no setter inherited
initMethods → List<String>
  List of initialization methods to invoke on the created pod.
  final
runtimeType → Type
  A representation of the runtime type of the object.
  no setter inherited
value → String?
  Optional pod name.
  final

## Methods

equalizedProperties() → List<Object?>
  Mixin-style contract for value-based equality, `hashCode`, and `toString`.
  override
equals(Object other) → bool
  Checks whether the given object is logically equivalent to this annotation.
  inherited
noSuchMethod(Invocation invocation) → dynamic
  Invoked when a nonexistent method or property is accessed.
  inherited
toString() → String
  Returns a string representation of this annotation.
  override

## Operators

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