summaryrefslogtreecommitdiffstats
path: root/comm/third_party/asn1js/src/Boolean.ts
blob: 3bcdb05ae2ed599d9509fb3334520876eca897be (plain)
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
import { BaseBlock, BaseBlockJson, BaseBlockParams } from "./BaseBlock";
import { LocalBooleanValueBlockParams, LocalBooleanValueBlock, LocalBooleanValueBlockJson } from "./internals/LocalBooleanValueBlock";
import { typeStore } from "./TypeStore";

export interface BooleanParams extends BaseBlockParams, LocalBooleanValueBlockParams { }
export type BooleanJson = BaseBlockJson<LocalBooleanValueBlockJson>;

export class Boolean extends BaseBlock<LocalBooleanValueBlock, LocalBooleanValueBlockJson> {

  static {
    typeStore.Boolean = this;
  }

  /**
   * Gets value
   * @since 3.0.0
   */
  public getValue(): boolean {
    return this.valueBlock.value;
  }
  /**
   * Sets value
   * @param value Boolean value
   * @since 3.0.0
   */
  public setValue(value: boolean): void {
    this.valueBlock.value = value;
  }

  public static override NAME = "BOOLEAN";

  constructor(parameters: BooleanParams = {}) {
    super(parameters, LocalBooleanValueBlock);

    this.idBlock.tagClass = 1; // UNIVERSAL
    this.idBlock.tagNumber = 1; // Boolean
  }

  protected override onAsciiEncoding(): string {
    return `${(this.constructor as typeof Boolean).NAME} : ${this.getValue}`;
  }

}