3939import com .fasterxml .jackson .databind .DeserializationFeature ;
4040import com .fasterxml .jackson .databind .ObjectMapper ;
4141import com .fasterxml .jackson .module .mrbean .MrBeanModule ;
42- import com .google .common .base .Function ;
43- import com .google .common .base .Predicate ;
4442import com .google .common .collect .Collections2 ;
4543import com .google .common .collect .ImmutableListMultimap ;
4644import com .google .common .collect .Iterables ;
@@ -98,12 +96,7 @@ public void parseIndex() throws Exception {
9896 }
9997
10098 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 );
107100
108101 for (ContributedPackage pack : packages ) {
109102 for (ContributedPlatform platform : pack .getPlatforms ()) {
@@ -141,7 +134,7 @@ private void mergeContributions(ContributionsIndex contributionsIndex, File inde
141134 }
142135 List <ContributedPlatform > platforms = contributedPackage .getPlatforms ();
143136 if (platforms == null ) {
144- platforms = new LinkedList <ContributedPlatform >();
137+ platforms = new LinkedList <>();
145138 }
146139 for (ContributedPlatform contributedPlatform : platforms ) {
147140 ContributedPlatform platform = targetPackage .findPlatform (contributedPlatform .getArchitecture (), contributedPlatform .getVersion ());
@@ -152,7 +145,7 @@ private void mergeContributions(ContributionsIndex contributionsIndex, File inde
152145 }
153146 List <ContributedTool > tools = contributedPackage .getTools ();
154147 if (tools == null ) {
155- tools = new LinkedList <ContributedTool >();
148+ tools = new LinkedList <>();
156149 }
157150 for (ContributedTool contributedTool : tools ) {
158151 ContributedTool tool = targetPackage .findTool (contributedTool .getName (), contributedTool .getVersion ());
@@ -191,7 +184,7 @@ public void syncWithFilesystem(File hardwareFolder) throws IOException {
191184 syncLocalPackagesFolder ();
192185 }
193186
194- public void syncBuiltInHardwareFolder (File hardwareFolder ) throws IOException {
187+ private void syncBuiltInHardwareFolder (File hardwareFolder ) throws IOException {
195188 if (index == null ) {
196189 return ;
197190 }
@@ -228,7 +221,7 @@ private void syncBuiltInPackageWithFilesystem(ContributedPackage pack, File hard
228221 }
229222 }
230223
231- public void syncLocalPackagesFolder () {
224+ private void syncLocalPackagesFolder () {
232225 if (!packagesFolder .isDirectory ()) {
233226 return ;
234227 }
@@ -299,7 +292,7 @@ public String toString() {
299292 }
300293
301294 public List <TargetPackage > createTargetPackages () {
302- List <TargetPackage > packages = new ArrayList <TargetPackage >();
295+ List <TargetPackage > packages = new ArrayList <>();
303296
304297 if (index == null ) {
305298 return packages ;
@@ -330,23 +323,14 @@ public List<TargetPackage> createTargetPackages() {
330323 }
331324 }
332325
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 ());
339329 });
340330
341331 return packages ;
342332 }
343333
344- /**
345- * Check if a ContributedTool is currently in use by an installed platform
346- *
347- * @param tool
348- * @return
349- */
350334 public boolean isContributedToolUsed (ContributedTool tool ) {
351335 for (ContributedPackage pack : index .getPackages ()) {
352336 for (ContributedPlatform platform : pack .getPlatforms ()) {
@@ -362,18 +346,13 @@ public boolean isContributedToolUsed(ContributedTool tool) {
362346 }
363347
364348 public Set <ContributedTool > getInstalledTools () {
365- Set <ContributedTool > tools = new HashSet <ContributedTool >();
349+ Set <ContributedTool > tools = new HashSet <>();
366350 if (index == null ) {
367351 return tools ;
368352 }
369353 for (ContributedPackage pack : index .getPackages ()) {
370354 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 );
377356
378357 for (Map .Entry <String , Collection <ContributedPlatform >> entry : platformsByName .asMap ().entrySet ()) {
379358 Collection <ContributedPlatform > platformsWithName = entry .getValue ();
@@ -406,14 +385,14 @@ public File getIndexFile(String name) {
406385
407386 public List <ContributedPackage > getPackages () {
408387 if (index == null ) {
409- return new LinkedList <ContributedPackage >();
388+ return new LinkedList <>();
410389 }
411390 return index .getPackages ();
412391 }
413392
414393 public List <String > getCategories () {
415394 if (index == null ) {
416- return new LinkedList <String >();
395+ return new LinkedList <>();
417396 }
418397 return index .getCategories ();
419398 }
@@ -425,9 +404,9 @@ public ContributedPlatform getInstalled(String packageName, String platformArch)
425404 return index .getInstalledPlatform (packageName , platformArch );
426405 }
427406
428- public List <ContributedPlatform > getInstalledPlatforms () {
407+ private List <ContributedPlatform > getInstalledPlatforms () {
429408 if (index == null ) {
430- return new LinkedList <ContributedPlatform >();
409+ return new LinkedList <>();
431410 }
432411 return index .getInstalledPlatforms ();
433412 }
@@ -437,12 +416,9 @@ public boolean isFolderInsidePlatform(final File folder) {
437416 }
438417
439418 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 );
446422 });
447423
448424 return platformOptional .orNull ();
0 commit comments