import { assert } from "../../../../core/assert.js";
import { Behavior } from "../Behavior.js";

/**
 *
 * @author Alex Goldring
 * @copyright Company Named Limited (c) 2026
 */
export class AbstractDecoratorBehavior extends Behavior {
    constructor() {
        super();

        /**
         *
         * @type {Behavior}
         * @protected
         */
        this.__source = null;
    }

    /**
     *
     * @return {Behavior}
     */
    getSource() {
        return this.__source;
    }

    /**
     *
     * @param {Behavior} source
     */
    setSource(source) {
        assert.defined(source, 'source');
        assert.notNull(source, 'source');

        assert.equal(source.isBehavior, true, 'source.isBehavior');

        this.__source = source;
    }

    initialize(context) {
        this.__source.initialize(context);
        super.initialize(context);
    }

    finalize() {
        this.__source.finalize();
        super.finalize();
    }
}

/**
 * @readonly
 * @type {boolean}
 */
AbstractDecoratorBehavior.prototype.isDecoratorBehavior = true;
