39
39
import com .fasterxml .jackson .databind .DeserializationFeature ;
40
40
import com .fasterxml .jackson .databind .ObjectMapper ;
41
41
import com .fasterxml .jackson .module .mrbean .MrBeanModule ;
42
- import com .google .common .base .Function ;
43
- import com .google .common .base .Predicate ;
44
42
import com .google .common .collect .Collections2 ;
45
43
import com .google .common .collect .ImmutableListMultimap ;
46
44
import com .google .common .collect .Iterables ;
@@ -98,12 +96,7 @@ public void parseIndex() throws Exception {
98
96
}
99
97
100
98
List <ContributedPackage > packages = index .getPackages ();
101
- Collection <ContributedPackage > packagesWithTools = Collections2 .filter (packages , new Predicate <ContributedPackage >() {
102
- @ Override
103
- public boolean apply (ContributedPackage input ) {
104
- return input .getTools () != null ;
105
- }
106
- });
99
+ Collection <ContributedPackage > packagesWithTools = Collections2 .filter (packages , input -> input .getTools () != null );
107
100
108
101
for (ContributedPackage pack : packages ) {
109
102
for (ContributedPlatform platform : pack .getPlatforms ()) {
@@ -141,7 +134,7 @@ private void mergeContributions(ContributionsIndex contributionsIndex, File inde
141
134
}
142
135
List <ContributedPlatform > platforms = contributedPackage .getPlatforms ();
143
136
if (platforms == null ) {
144
- platforms = new LinkedList <ContributedPlatform >();
137
+ platforms = new LinkedList <>();
145
138
}
146
139
for (ContributedPlatform contributedPlatform : platforms ) {
147
140
ContributedPlatform platform = targetPackage .findPlatform (contributedPlatform .getArchitecture (), contributedPlatform .getVersion ());
@@ -152,7 +145,7 @@ private void mergeContributions(ContributionsIndex contributionsIndex, File inde
152
145
}
153
146
List <ContributedTool > tools = contributedPackage .getTools ();
154
147
if (tools == null ) {
155
- tools = new LinkedList <ContributedTool >();
148
+ tools = new LinkedList <>();
156
149
}
157
150
for (ContributedTool contributedTool : tools ) {
158
151
ContributedTool tool = targetPackage .findTool (contributedTool .getName (), contributedTool .getVersion ());
@@ -191,7 +184,7 @@ public void syncWithFilesystem(File hardwareFolder) throws IOException {
191
184
syncLocalPackagesFolder ();
192
185
}
193
186
194
- public void syncBuiltInHardwareFolder (File hardwareFolder ) throws IOException {
187
+ private void syncBuiltInHardwareFolder (File hardwareFolder ) throws IOException {
195
188
if (index == null ) {
196
189
return ;
197
190
}
@@ -228,7 +221,7 @@ private void syncBuiltInPackageWithFilesystem(ContributedPackage pack, File hard
228
221
}
229
222
}
230
223
231
- public void syncLocalPackagesFolder () {
224
+ private void syncLocalPackagesFolder () {
232
225
if (!packagesFolder .isDirectory ()) {
233
226
return ;
234
227
}
@@ -299,7 +292,7 @@ public String toString() {
299
292
}
300
293
301
294
public List <TargetPackage > createTargetPackages () {
302
- List <TargetPackage > packages = new ArrayList <TargetPackage >();
295
+ List <TargetPackage > packages = new ArrayList <>();
303
296
304
297
if (index == null ) {
305
298
return packages ;
@@ -330,23 +323,14 @@ public List<TargetPackage> createTargetPackages() {
330
323
}
331
324
}
332
325
333
- Collections .sort (packages , new Comparator <TargetPackage >() {
334
- @ Override
335
- public int compare (TargetPackage p1 , TargetPackage p2 ) {
336
- assert p1 .getId () != null && p2 .getId () != null ;
337
- return p1 .getId ().toLowerCase ().compareTo (p2 .getId ().toLowerCase ());
338
- }
326
+ Collections .sort (packages , (package1 , package2 ) -> {
327
+ assert package1 .getId () != null && package2 .getId () != null ;
328
+ return package1 .getId ().toLowerCase ().compareTo (package2 .getId ().toLowerCase ());
339
329
});
340
330
341
331
return packages ;
342
332
}
343
333
344
- /**
345
- * Check if a ContributedTool is currently in use by an installed platform
346
- *
347
- * @param tool
348
- * @return
349
- */
350
334
public boolean isContributedToolUsed (ContributedTool tool ) {
351
335
for (ContributedPackage pack : index .getPackages ()) {
352
336
for (ContributedPlatform platform : pack .getPlatforms ()) {
@@ -362,18 +346,13 @@ public boolean isContributedToolUsed(ContributedTool tool) {
362
346
}
363
347
364
348
public Set <ContributedTool > getInstalledTools () {
365
- Set <ContributedTool > tools = new HashSet <ContributedTool >();
349
+ Set <ContributedTool > tools = new HashSet <>();
366
350
if (index == null ) {
367
351
return tools ;
368
352
}
369
353
for (ContributedPackage pack : index .getPackages ()) {
370
354
Collection <ContributedPlatform > platforms = pack .getPlatforms ().stream ().filter (new InstalledPredicate ()).collect (Collectors .toList ());
371
- ImmutableListMultimap <String , ContributedPlatform > platformsByName = Multimaps .index (platforms , new Function <ContributedPlatform , String >() {
372
- @ Override
373
- public String apply (ContributedPlatform contributedPlatform ) {
374
- return contributedPlatform .getName ();
375
- }
376
- });
355
+ ImmutableListMultimap <String , ContributedPlatform > platformsByName = Multimaps .index (platforms , ContributedPlatform ::getName );
377
356
378
357
for (Map .Entry <String , Collection <ContributedPlatform >> entry : platformsByName .asMap ().entrySet ()) {
379
358
Collection <ContributedPlatform > platformsWithName = entry .getValue ();
@@ -406,14 +385,14 @@ public File getIndexFile(String name) {
406
385
407
386
public List <ContributedPackage > getPackages () {
408
387
if (index == null ) {
409
- return new LinkedList <ContributedPackage >();
388
+ return new LinkedList <>();
410
389
}
411
390
return index .getPackages ();
412
391
}
413
392
414
393
public List <String > getCategories () {
415
394
if (index == null ) {
416
- return new LinkedList <String >();
395
+ return new LinkedList <>();
417
396
}
418
397
return index .getCategories ();
419
398
}
@@ -425,9 +404,9 @@ public ContributedPlatform getInstalled(String packageName, String platformArch)
425
404
return index .getInstalledPlatform (packageName , platformArch );
426
405
}
427
406
428
- public List <ContributedPlatform > getInstalledPlatforms () {
407
+ private List <ContributedPlatform > getInstalledPlatforms () {
429
408
if (index == null ) {
430
- return new LinkedList <ContributedPlatform >();
409
+ return new LinkedList <>();
431
410
}
432
411
return index .getInstalledPlatforms ();
433
412
}
@@ -437,12 +416,9 @@ public boolean isFolderInsidePlatform(final File folder) {
437
416
}
438
417
439
418
public ContributedPlatform getPlatformByFolder (final File folder ) {
440
- com .google .common .base .Optional <ContributedPlatform > platformOptional = Iterables .tryFind (getInstalledPlatforms (), new Predicate <ContributedPlatform >() {
441
- @ Override
442
- public boolean apply (ContributedPlatform contributedPlatform ) {
443
- assert contributedPlatform .getInstalledFolder () != null ;
444
- return FileUtils .isSubDirectory (contributedPlatform .getInstalledFolder (), folder );
445
- }
419
+ com .google .common .base .Optional <ContributedPlatform > platformOptional = Iterables .tryFind (getInstalledPlatforms (), contributedPlatform -> {
420
+ assert contributedPlatform .getInstalledFolder () != null ;
421
+ return FileUtils .isSubDirectory (contributedPlatform .getInstalledFolder (), folder );
446
422
});
447
423
448
424
return platformOptional .orNull ();
0 commit comments