@@ -73,17 +73,10 @@ static boolean isOsFamily(String osSpec) {
73
73
}
74
74
75
75
static boolean isOsFamily (List <String > families , boolean defaultMatch ) {
76
- if (families != null && !families .isEmpty ()) {
77
- for (String family : families ) {
78
- if (Os .isFamily (family )) {
79
- return true ;
80
- }
81
- }
82
-
83
- return false ;
84
- } else {
76
+ if (families == null || families .isEmpty ()) {
85
77
return defaultMatch ;
86
78
}
79
+ return families .stream ().anyMatch (Os ::isFamily );
87
80
}
88
81
89
82
/**
@@ -139,10 +132,6 @@ static String getMavenVersion(File mavenHome) throws IOException {
139
132
return null ;
140
133
}
141
134
142
- static boolean isMavenVersion (String mavenSpec ) {
143
- return isMavenVersion (mavenSpec , getMavenVersion ());
144
- }
145
-
146
135
static boolean isMavenVersion (String mavenSpec , String actualVersion ) {
147
136
List <String > includes = new ArrayList <>();
148
137
List <String > excludes = new ArrayList <>();
@@ -157,15 +146,6 @@ static String getJreVersion() {
157
146
return System .getProperty ("java.version" , "" );
158
147
}
159
148
160
- static String getJreVersion (File javaHome ) {
161
- // @todo detect actual version
162
- return null ;
163
- }
164
-
165
- static boolean isJreVersion (String jreSpec ) {
166
- return isJreVersion (jreSpec , getJreVersion ());
167
- }
168
-
169
149
static boolean isJreVersion (String jreSpec , String actualJreVersion ) {
170
150
List <String > includes = new ArrayList <>();
171
151
List <String > excludes = new ArrayList <>();
@@ -176,33 +156,27 @@ static boolean isJreVersion(String jreSpec, String actualJreVersion) {
176
156
return isJreVersion (jreVersion , includes , true ) && !isJreVersion (jreVersion , excludes , false );
177
157
}
178
158
179
- static boolean isJreVersion (List <Integer > jreVersion , List <String > versionPatterns , boolean defaultMatch ) {
180
- if (versionPatterns != null && !versionPatterns .isEmpty ()) {
181
- for (String versionPattern : versionPatterns ) {
182
- if (isJreVersion (jreVersion , versionPattern )) {
183
- return true ;
184
- }
185
- }
186
-
187
- return false ;
188
- } else {
159
+ static boolean isJreVersion (List <Integer > jreVersions , List <String > versionPatterns , boolean defaultMatch ) {
160
+ if (versionPatterns == null || versionPatterns .isEmpty ()) {
189
161
return defaultMatch ;
190
162
}
163
+
164
+ return versionPatterns .stream ().anyMatch (versionPattern -> isJreVersion (jreVersions , versionPattern ));
191
165
}
192
166
193
- static boolean isJreVersion (List <Integer > jreVersion , String versionPattern ) {
167
+ static boolean isJreVersion (List <Integer > jreVersions , String versionPattern ) {
194
168
List <Integer > checkVersion = parseVersion (versionPattern );
195
169
196
170
if (versionPattern .endsWith ("+" )) {
197
171
// 1.5+ <=> [1.5,)
198
- return compareVersions (jreVersion , checkVersion ) >= 0 ;
172
+ return compareVersions (jreVersions , checkVersion ) >= 0 ;
199
173
} else if (versionPattern .endsWith ("-" )) {
200
174
// 1.5- <=> (,1.5)
201
- return compareVersions (jreVersion , checkVersion ) < 0 ;
175
+ return compareVersions (jreVersions , checkVersion ) < 0 ;
202
176
} else {
203
177
// 1.5 <=> [1.5,1.6)
204
- return checkVersion .size () <= jreVersion .size ()
205
- && checkVersion .equals (jreVersion .subList (0 , checkVersion .size ()));
178
+ return checkVersion .size () <= jreVersions .size ()
179
+ && checkVersion .equals (jreVersions .subList (0 , checkVersion .size ()));
206
180
}
207
181
}
208
182
0 commit comments