"use strict";
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0
Object.defineProperty(exports, "__esModule", { value: true });
exports.BlockBody = exports.BlockBodyType = void 0;
/**
 * All of the block body types.
 */
var BlockBodyType;
(function (BlockBodyType) {
    /// A Basic block body.
    BlockBodyType[BlockBodyType["Basic"] = 0] = "Basic";
    /// A Validation block body.
    BlockBodyType[BlockBodyType["Validation"] = 1] = "Validation";
})(BlockBodyType = exports.BlockBodyType || (exports.BlockBodyType = {}));
class BlockBody {
    /**
     * @param type The type of BlockBody.
     */
    constructor(type) {
        this.type = type;
    }
    /**
     * Checks whether the block body is a `BasicBlockBody`.
     * @returns true if it is, otherwise false
     */
    isBasic() {
        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
     */
    asBasic() {
        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
     */
    isValidation() {
        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
     */
    asValidation() {
        if (this.isValidation()) {
            return this;
        }
        else {
            throw new Error('invalid downcast of non-ValidationBlockBody');
        }
    }
}
exports.BlockBody = BlockBody;
//# sourceMappingURL=block-body.js.map