-
Notifications
You must be signed in to change notification settings - Fork 18
/
e-shape-action-value-change-cursor.ts
54 lines (46 loc) · 1.86 KB
/
e-shape-action-value-change-cursor.ts
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
/*
* Copyright (C) 2019 Toshiba Corporation
* SPDX-License-Identifier: Apache-2.0
*/
import { EShapeResourceManagerDeserialization } from "../e-shape-resource-manager-deserialization";
import { EShapeResourceManagerSerialization } from "../e-shape-resource-manager-serialization";
import { EShapeActionRuntimeChangeCursor } from "./e-shape-action-runtime-change-cursor";
import { EShapeActionValue } from "./e-shape-action-value";
import { EShapeActionValueBase } from "./e-shape-action-value-base";
import { EShapeActionValueType } from "./e-shape-action-value-type";
import { EShapeActionValues } from "./e-shape-action-values";
export type EShapeActionValueChangeCursorSerialized = [
typeof EShapeActionValueType.CHANGE_CURSOR,
number,
number
];
export class EShapeActionValueChangeCursor extends EShapeActionValueBase {
readonly name: string;
constructor(condition: string, name: string) {
super(EShapeActionValueType.CHANGE_CURSOR, condition);
this.name = name;
}
isEquals(value: EShapeActionValue): boolean {
return (
super.isEquals(value) &&
value instanceof EShapeActionValueChangeCursor &&
this.name === value.name
);
}
toRuntime(): EShapeActionRuntimeChangeCursor {
return new EShapeActionRuntimeChangeCursor(this);
}
serialize(manager: EShapeResourceManagerSerialization): number {
const conditionId = manager.addResource(this.condition);
const nameId = manager.addResource(this.name);
return manager.addResource(`[${this.type},${conditionId},${nameId}]`);
}
static deserialize(
serialized: EShapeActionValueChangeCursorSerialized,
manager: EShapeResourceManagerDeserialization
): EShapeActionValueChangeCursor {
const condition = EShapeActionValues.toResource(1, serialized, manager.resources);
const name = EShapeActionValues.toResource(2, serialized, manager.resources);
return new EShapeActionValueChangeCursor(condition, name);
}
}