// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
/**
 * All of the block body types.
 */
export var BlockBodyType;
(function (BlockBodyType) {
    /// A Basic block body.
    BlockBodyType[BlockBodyType["Basic"] = 0] = "Basic";
    /// A Validation block body.
    BlockBodyType[BlockBodyType["Validation"] = 1] = "Validation";
})(BlockBodyType || (BlockBodyType = {}));
var BlockBody = /** @class */ (function () {
    /**
     * @param type The type of BlockBody.
     */
    function BlockBody(type) {
        this.type = type;
    }
    /**
     * Checks whether the block body is a `BasicBlockBody`.
     * @returns true if it is, otherwise false
     */
    BlockBody.prototype.isBasic = function () {
        return this.type === BlockBodyType.Basic;
    };
    /**
     * Gets the block body as an actual `BasicBlockBody`.
     * NOTE: Will throw an error if the block is not a `BasicBlockBody`.
     * @returns The BasicBlockBody
     */
    BlockBody.prototype.asBasic = function () {
        if (this.isBasic()) {
            return this;
        }
        else {
            throw new Error('invalid downcast of non-BasicBlockBody');
        }
    };
    /**
     * Checks whether the block body is a `ValidationBlockBody`.
     * @returns true if it is, otherwise false
     */
    BlockBody.prototype.isValidation = function () {
        return this.type === BlockBodyType.Validation;
    };
    /**
     * Gets the block body as an actual `ValidationBlockBody`.
     * NOTE: Will throw an error if the block is not a `ValidationBlockBody`.
     * @returns The ValidationBlockBody
     */
    BlockBody.prototype.asValidation = function () {
        if (this.isValidation()) {
            return this;
        }
        else {
            throw new Error('invalid downcast of non-ValidationBlockBody');
        }
    };
    return BlockBody;
}());
export { BlockBody };
//# sourceMappingURL=block-body.js.map