@@ -32,22 +32,16 @@ public enum Platform {
32
32
/**
33
33
* Never returned, but can be used to request a browser running on any version of Windows.
34
34
*/
35
- WINDOWS ("" ) {
36
- @ Override
37
- public boolean is (Platform compareWith ) {
38
- return compareWith == WINDOWS || compareWith == XP
39
- || compareWith == VISTA || compareWith == WIN8 ;
40
- }
41
- },
35
+ WINDOWS ("" ) {},
42
36
43
37
/**
44
38
* For versions of Windows that "feel like" Windows XP. These are ones that store files in
45
39
* "\Program Files\" and documents under "\\documents and settings\\username"
46
40
*/
47
41
XP ("Windows Server 2003" , "xp" , "windows" , "winnt" ) {
48
42
@ Override
49
- public boolean is ( Platform compareWith ) {
50
- return compareWith == WINDOWS || compareWith == XP ;
43
+ public Platform family ( ) {
44
+ return WINDOWS ;
51
45
}
52
46
},
53
47
@@ -56,8 +50,8 @@ public boolean is(Platform compareWith) {
56
50
*/
57
51
VISTA ("windows vista" , "Windows Server 2008" , "windows 7" , "win7" ) {
58
52
@ Override
59
- public boolean is ( Platform compareWith ) {
60
- return compareWith == WINDOWS || compareWith == VISTA ;
53
+ public Platform family ( ) {
54
+ return WINDOWS ;
61
55
}
62
56
},
63
57
@@ -66,15 +60,15 @@ public boolean is(Platform compareWith) {
66
60
*/
67
61
WIN8 ("Windows Server 2012" , "windows 8" , "win8" ) {
68
62
@ Override
69
- public boolean is ( Platform compareWith ) {
70
- return compareWith == WINDOWS || compareWith == WIN8 ;
63
+ public Platform family ( ) {
64
+ return WINDOWS ;
71
65
}
72
66
},
73
67
74
68
WIN8_1 ("windows 8.1" , "win8.1" ) {
75
69
@ Override
76
- public boolean is ( Platform compareWith ) {
77
- return compareWith == WINDOWS || compareWith == WIN8_1 ;
70
+ public Platform family ( ) {
71
+ return WINDOWS ;
78
72
}
79
73
},
80
74
@@ -87,8 +81,8 @@ public boolean is(Platform compareWith) {
87
81
88
82
LINUX ("linux" ) {
89
83
@ Override
90
- public boolean is ( Platform compareWith ) {
91
- return compareWith == UNIX || compareWith == LINUX ;
84
+ public Platform family ( ) {
85
+ return UNIX ;
92
86
}
93
87
},
94
88
@@ -98,8 +92,8 @@ public String getLineEnding() {
98
92
}
99
93
100
94
@ Override
101
- public boolean is ( Platform compareWith ) {
102
- return compareWith == LINUX || compareWith == ANDROID ;
95
+ public Platform family ( ) {
96
+ return LINUX ;
103
97
}
104
98
},
105
99
@@ -109,7 +103,7 @@ public boolean is(Platform compareWith) {
109
103
ANY ("" ) {
110
104
@ Override
111
105
public boolean is (Platform compareWith ) {
112
- return true ;
106
+ return this == compareWith ;
113
107
}
114
108
};
115
109
@@ -230,7 +224,17 @@ private static boolean isBetterMatch(String previous, String matcher) {
230
224
* @return true if platforms are approximately similar, false otherwise
231
225
*/
232
226
public boolean is (Platform compareWith ) {
233
- return this .equals (compareWith );
227
+ return this == compareWith || this .family ().is (compareWith );
228
+ }
229
+
230
+ /**
231
+ * Returns a platform that represents a family for the current platform. For instance
232
+ * the LINUX if a part of the UNIX family, the XP is a part of the WINDOWS family.
233
+ *
234
+ * @return the family platform for the current one
235
+ */
236
+ public Platform family () {
237
+ return ANY ;
234
238
}
235
239
236
240
private boolean isCurrentPlatform (String osName , String matchAgainst ) {
0 commit comments