All files / src/libs/Search SearchElement.ts

100% Statements 8/8
100% Branches 1/1
100% Functions 5/5
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56        5x   97x               97x 97x                           2x               1x             73x               11x      
/**
 * Abstract class representing a search element.
 * This class serves as the base class for different types of search elements, such as search terms and search operators.
 */
export default abstract class SearchElement {
    protected _value: string;
    protected _isNegated = false;
 
    /**
     * Constructs a new SearchElement with the given value.
     * @param value The value of the search element.
     * @param negated The negated value of the search element.
     */
    constructor(value: string, negated = false) {
        this._value = value;
        this._isNegated = negated;
    }
 
    /**
     * Abstract getter to determine if the element is an operator.
     * This method should be implemented by subclasses to specify whether the element is an operator.
     * @returns {boolean} True if the element is an operator, otherwise false.
     */
    abstract get isOperator(): boolean;
 
    /**
     * Gets the value of the search element.
     */
    public get value(): string {
        return this._value;
    }
 
    /**
     * Sets the value of the search element.
     * @param newValue - The new value to be set.
     */
    public set value(newValue: string) {
        this._value = newValue;
    }
 
    /**
     * Gets the negated value of the search element.
     */
    public get isNegated(): boolean {
        return this._isNegated;
    }
 
    /**
     * Sets the negated value of the search element.
     * @param newValue - The new negated value to be set.
     */
    public set isNegated(newValue: boolean) {
        this._isNegated = newValue;
    }
}
 
Zur TypeDoc-Dokumentation