Add TypeChecker and use its methods wherever possible.

This commit is contained in:
László Monda
2016-03-30 01:59:05 +02:00
parent 94e5d55d8f
commit 0edde3236a
7 changed files with 18 additions and 20 deletions
@@ -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;