import { PortDirection } from "../../../../../../core/model/node-graph/node/PortDirection.js";
import { objectKeyByValue } from "../../../../../../core/model/object/objectKeyByValue.js";

export class FunctionParameterSpecification {

    /**
     *
     * @type {PortDirection|number}
     */
    direction = PortDirection.In;


    /**
     * @type {BinaryDataType}
     */
    type = null;

    /**
     *
     * @param {PortDirection} direction
     * @param {BinaryDataType} type
     *
     * @returns {FunctionParameterSpecification}
     */
    static from(direction, type) {
        const r = new FunctionParameterSpecification();


        r.direction = direction;
        r.type = type;

        return r;
    }

    /**
     *
     * @param {FunctionParameterSpecification} other
     * @returns {boolean}
     */
    equals(other) {

        if (this.direction !== other.direction) {
            return false;
        }

        if (!this.type.equals(other.type)) {
            return false;
        }

        // all is equal
        return true;
    }

    toString() {
        return `FunctionParameterSpecification{ direction:${objectKeyByValue(PortDirection, this.direction)}, type:${this.type} }`;
    }
}
