aboutsummaryrefslogtreecommitdiff
path: root/src/fields/BooleanField.ts
blob: d319b4021f286d0ce9e59c5ef1c21f2d4ff314f8 (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
import { BasicField } from "./BasicField";
import { FieldId } from "./Field";
import { Types } from "../server/Message";

export class BooleanField extends BasicField<boolean> {
    constructor(data: boolean = false as boolean, id?: FieldId, save: boolean = true as boolean) {
        super(data, save, id);
    }

    ToScriptString(): string {
        return `new BooleanField("${this.Data}")`;
    }

    Copy() {
        return new BooleanField(this.Data);
    }

    ToJson(): { type: Types; data: boolean; _id: string } {
        return {
            type: Types.Boolean,
            data: this.Data,
            _id: this.Id
        };
    }
}