17
17
18
18
package org .openqa .grid .common ;
19
19
20
+ import com .google .common .collect .ImmutableList ;
21
+
20
22
import org .openqa .grid .common .exception .GridConfigurationException ;
21
23
22
24
import java .util .ArrayList ;
25
27
public enum GridRole {
26
28
NOT_GRID , HUB , NODE ;
27
29
30
+ private static List <String > rcAliases = new ImmutableList .Builder <String >()
31
+ .add ("rc" )
32
+ .add ("remotecontrol" )
33
+ .add ("remote-control" )
34
+ .build ();
35
+
36
+ private static List <String > wdAliases = new ImmutableList .Builder <String >()
37
+ .add ("wd" )
38
+ .add ("webdriver" )
39
+ .build ();
40
+
41
+ private static List <String > nodeAliases = new ImmutableList .Builder <String >()
42
+ .add ("node" )
43
+ .addAll (rcAliases )
44
+ .addAll (wdAliases )
45
+ .build ();
46
+
28
47
/**
29
48
* finds the requested role from the parameters.
30
49
*
@@ -42,7 +61,7 @@ public static GridRole find(String[] args) {
42
61
"-role needs to be followed by the role of this component in the grid." );
43
62
} else {
44
63
String role = args [i + 1 ].toLowerCase ();
45
- if (NodeAliases () .contains (role )) {
64
+ if (nodeAliases .contains (role )) {
46
65
return NODE ;
47
66
} else if ("hub" .equals (role )) {
48
67
return HUB ;
@@ -56,26 +75,11 @@ public static GridRole find(String[] args) {
56
75
return NOT_GRID ;
57
76
}
58
77
59
- private static List <String > NodeAliases () {
60
- List <String > res = new ArrayList <String >();
61
- res .add ("node" );
62
- res .addAll (RCAliases ());
63
- res .addAll (WDAliases ());
64
- return res ;
65
- }
66
-
67
- public static List <String > RCAliases () {
68
- List <String > res = new ArrayList <String >();
69
- res .add ("rc" );
70
- res .add ("remotecontrol" );
71
- res .add ("remote-control" );
72
- return res ;
78
+ public static boolean isRC (String nodeType ) {
79
+ return rcAliases .contains (nodeType );
73
80
}
74
81
75
- public static List <String > WDAliases () {
76
- List <String > res = new ArrayList <String >();
77
- res .add ("wd" );
78
- res .add ("webdriver" );
79
- return res ;
82
+ public static boolean isWebDriver (String nodeType ) {
83
+ return wdAliases .contains (nodeType );
80
84
}
81
85
}
0 commit comments