-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathDriverChecker.js
45 lines (37 loc) · 1.12 KB
/
DriverChecker.js
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
/** @namespace drivers */
/**
* A goal of the class is to check if drivers are correctly implemented.
*
* @author Darko Lukic <[email protected]>
* @memberOf drivers
*/
class DriverChecker {
static check(driver) {
let groups;
if (typeof driver.getGroups === 'function') {
groups = driver.getGroups();
} else {
throw TypeError(driver.constructor.name + ' doesn\'t have member getGroups()');
}
for (let group of groups) {
switch (group) {
case 'position':
DriverChecker._checkPosition(driver);
break;
case 'terrain':
DriverChecker._checkTerrain(driver);
break;
}
}
}
static _checkPosition(driver) {
let driverClassName = driver.constructor.name;
// Check getPosition()
if (typeof driver.getPosition !== 'function') {
throw TypeError(driverClassName + ' requires method getPosition()');
}
}
static _checkTerrain(driver) {
}
}
module.exports = DriverChecker;