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

export class MarkerNodeMatcherByType extends MarkerNodeMatcher {
    constructor() {
        super();

        /**
         *
         * @type {String}
         */
        this.type = null;
    }

    /**
     *
     * @param {String} type
     * @returns {MarkerNodeMatcherByType}
     */
    static from(type) {
        assert.isString(type, 'type');

        const r = new MarkerNodeMatcherByType();

        r.type = type;

        return r;
    }

    match(node) {
        assert.defined(node, 'node');
        assert.ok(node.isMarkerNode, 'node.isMarkerNode !== true');

        return node.type === this.type;
    }
}
