11
11
package com .redhat .devtools .intellij .common .utils ;
12
12
13
13
import com .intellij .openapi .application .ApplicationManager ;
14
- import com .intellij .openapi .progress .EmptyProgressIndicator ;
15
14
import com .intellij .openapi .progress .ProgressIndicator ;
16
15
import com .intellij .openapi .progress .ProgressManager ;
17
16
import com .intellij .openapi .progress .Task ;
18
17
import com .intellij .openapi .ui .Messages ;
19
- import com .intellij .openapi .util .Computable ;
18
+ import com .intellij .openapi .util .text . StringUtil ;
20
19
import com .intellij .util .io .HttpRequests ;
21
20
import com .redhat .devtools .intellij .common .CommonConstants ;
22
21
import com .twelvemonkeys .lang .Platform ;
28
27
import org .apache .commons .compress .compressors .CompressorStreamFactory ;
29
28
import org .apache .commons .io .FilenameUtils ;
30
29
import org .apache .commons .io .IOUtils ;
31
- import org .apache .commons .lang .StringUtils ;
32
30
import org .jetbrains .annotations .NotNull ;
33
31
34
32
import java .io .BufferedInputStream ;
45
43
import java .util .Map ;
46
44
import java .util .concurrent .CompletableFuture ;
47
45
import java .util .concurrent .ExecutionException ;
48
- import java .util .concurrent .atomic .AtomicReference ;
49
- import java .util .function .Consumer ;
50
- import java .util .function .Function ;
51
46
import java .util .function .UnaryOperator ;
47
+ import java .util .regex .Matcher ;
52
48
import java .util .regex .Pattern ;
53
49
54
50
public class DownloadHelper {
@@ -60,9 +56,9 @@ public class DownloadHelper {
60
56
}
61
57
});
62
58
63
- private static final UnaryOperator <InputStream > UNTAR = (input -> new TarArchiveInputStream ( input ) );
59
+ private static final UnaryOperator <InputStream > UNTAR = (TarArchiveInputStream :: new );
64
60
65
- private static final UnaryOperator <InputStream > UNZIP = (input -> new ZipArchiveInputStream ( input ) );
61
+ private static final UnaryOperator <InputStream > UNZIP = (ZipArchiveInputStream :: new );
66
62
67
63
private static final Map <String , UnaryOperator <InputStream >> MAPPERS = new HashMap <>();
68
64
@@ -223,15 +219,15 @@ public CompletableFuture<String> downloadIfRequiredAsync(String toolName, URL ur
223
219
224
220
private boolean isDownloadAllowed (String tool , String currentVersion , String requiredVersion ) {
225
221
return UIHelper .executeInUI (() ->
226
- Messages .showYesNoCancelDialog (StringUtils .isEmpty (currentVersion ) ? tool + " not found , do you want to download " + tool + " " + requiredVersion + " ?" : tool + " " + currentVersion + " found, required version is " + requiredVersion + ", do you want to download " + tool + " ?" , tool + " tool required" , Messages .getQuestionIcon ()) == Messages .YES );
222
+ Messages .showYesNoCancelDialog (StringUtil .isEmpty (currentVersion ) ? tool + " not found , do you want to download " + tool + " " + requiredVersion + " ?" : tool + " " + currentVersion + " found, required version is " + requiredVersion + ", do you want to download " + tool + " ?" , tool + " tool required" , Messages .getQuestionIcon ()) == Messages .YES );
227
223
}
228
224
229
225
private boolean areCompatible (String version , String versionMatchRegExpr ) {
230
226
boolean compatible = true ;
231
- if (StringUtils . isNotBlank (versionMatchRegExpr )) {
227
+ if (! StringUtil . isEmptyOrSpaces (versionMatchRegExpr )) {
232
228
Pattern pattern = Pattern .compile (versionMatchRegExpr );
233
229
compatible = pattern .matcher (version ).matches ();
234
- } else if (StringUtils . isBlank (version )) {
230
+ } else if (StringUtil . isEmptyOrSpaces (version )) {
235
231
compatible = false ;
236
232
}
237
233
return compatible ;
@@ -245,12 +241,13 @@ private String getVersionFromPath(ToolsConfig.Tool tool, ToolsConfig.Platform pl
245
241
String output = ExecHelper .execute (platform .getCmdFileName (), false , arguments );
246
242
try (BufferedReader reader = new BufferedReader (new StringReader (output ))) {
247
243
version = reader .lines ().
248
- map (line -> pattern . matcher ( line ) ).
249
- filter (matcher -> matcher . matches () ).
244
+ map (pattern :: matcher ).
245
+ filter (Matcher :: matches ).
250
246
map (matcher -> matcher .group (1 )).
251
247
findFirst ().orElse ("" );
252
248
}
253
249
} catch (IOException e ) {
250
+ // swallow
254
251
}
255
252
return version ;
256
253
0 commit comments