File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
arduino-core/src/cc/arduino/contributions/libraries Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change 3030package cc .arduino .contributions .libraries ;
3131
3232import cc .arduino .contributions .DownloadableContributionBuiltInAtTheBottomComparator ;
33+ import cc .arduino .contributions .VersionComparator ;
3334import cc .arduino .contributions .libraries .filters .LibraryWithNamePredicate ;
3435
3536import java .util .*;
@@ -91,13 +92,14 @@ public List<String> getTypes() {
9192 }
9293
9394 public Optional <ContributedLibrary > getInstalled (String name ) {
94- List <ContributedLibrary > installedReleases = find (name ).stream ().filter (l -> l .isLibraryInstalled ()).collect (Collectors .toList ());
95- Collections .sort (installedReleases , new DownloadableContributionBuiltInAtTheBottomComparator ());
96-
97- if (installedReleases .isEmpty ()) {
98- return Optional .empty ();
99- }
100-
101- return Optional .of (installedReleases .get (0 ));
95+ return find (name ).stream () //
96+ .filter (l -> l .isLibraryInstalled ()) //
97+ .reduce ((x , y ) -> {
98+ if (x .isIDEBuiltIn () == y .isIDEBuiltIn ()) {
99+ return VersionComparator .max (x , y );
100+ } else {
101+ return x .isIDEBuiltIn () ? y : x ;
102+ }
103+ });
102104 }
103105}
You can’t perform that action at this time.
0 commit comments