Add TypeChecker and use its methods wherever possible.
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction> {
|
||||
|
||||
static keyActionTypeString = 'keystroke';
|
||||
static firstValidScancode = 1;
|
||||
static lastValidScancode = 231;
|
||||
|
||||
modifierMask: number;
|
||||
|
||||
@@ -13,17 +11,12 @@ class KeystrokeAction extends KeyAction implements Serializable<KeystrokeAction>
|
||||
}
|
||||
|
||||
set scancode(value) {
|
||||
if (!KeystrokeAction.isScancodeValid(value)) {
|
||||
if (!TypeChecker.isScancodeValid(value)) {
|
||||
throw 'Invalid KeystrokeAction.scancode: ${scancode}';
|
||||
}
|
||||
this._scancode = value;
|
||||
}
|
||||
|
||||
static isScancodeValid(scancode) {
|
||||
return KeystrokeAction.firstValidScancode <= scancode &&
|
||||
scancode <= KeystrokeAction.lastValidScancode;
|
||||
}
|
||||
|
||||
fromJsObject(jsObject: any): KeystrokeAction {
|
||||
this.scancode = jsObject.scancode;
|
||||
this.modifierMask = jsObject.modifierMask;
|
||||
|
||||
Reference in New Issue
Block a user