File tree Expand file tree Collapse file tree 6 files changed +18
-14
lines changed
cc/arduino/contributions/libraries
cc/arduino/contributions/libraries Expand file tree Collapse file tree 6 files changed +18
-14
lines changed Original file line number Diff line number Diff line change @@ -47,13 +47,17 @@ public LibraryByTypeComparator(LibraryTypeComparator libraryTypeComparator) {
4747
4848 @ Override
4949 public int compare (UserLibrary o1 , UserLibrary o2 ) {
50- if (o1 .getTypes () == null ) {
50+ if (o1 .getTypes ().isEmpty () && o2 .getTypes ().isEmpty ()) {
51+ return 0 ;
52+ }
53+ if (o1 .getTypes ().isEmpty ()) {
5154 return 1 ;
5255 }
53- if (o2 .getTypes () == null ) {
56+ if (o2 .getTypes (). isEmpty () ) {
5457 return -1 ;
5558 }
56- return libraryTypeComparator .compare (o1 .getTypes ().get (0 ), o2 .getTypes ().get (0 ));
59+ return libraryTypeComparator .compare (o1 .getTypes ().get (0 ),
60+ o2 .getTypes ().get (0 ));
5761 }
5862
5963}
Original file line number Diff line number Diff line change @@ -37,10 +37,13 @@ public class LibraryOfSameTypeComparator implements Comparator<UserLibrary> {
3737
3838 @ Override
3939 public int compare (UserLibrary o1 , UserLibrary o2 ) {
40- if (o1 .getTypes () == null ) {
40+ if (o1 .getTypes ().isEmpty () && o2 .getTypes ().isEmpty ()) {
41+ return 0 ;
42+ }
43+ if (o1 .getTypes ().isEmpty ()) {
4144 return 1 ;
4245 }
43- if (o2 .getTypes () == null ) {
46+ if (o2 .getTypes (). isEmpty () ) {
4447 return -1 ;
4548 }
4649 if (!o1 .getTypes ().get (0 ).equals (o2 .getTypes ().get (0 ))) {
Original file line number Diff line number Diff line change @@ -1193,10 +1193,7 @@ public void rebuildExamplesMenu(JMenu menu) {
11931193 if (location == Location .IDE_BUILTIN ) {
11941194 if (compatible ) {
11951195 // only compatible IDE libs are shown
1196- boolean retired = false ;
1197- List <String > types = lib .getTypes ();
1198- if (types != null ) retired = types .contains ("Retired" );
1199- if (retired ) {
1196+ if (lib .getTypes ().contains ("Retired" )) {
12001197 retiredIdeLibs .add (lib );
12011198 } else {
12021199 ideLibs .add (lib );
@@ -1214,7 +1211,7 @@ public void rebuildExamplesMenu(JMenu menu) {
12141211 } else if (location == Location .SKETCHBOOK ) {
12151212 if (compatible ) {
12161213 // libraries promoted from sketchbook (behave as builtin)
1217- if (lib .getTypes () != null && lib .getTypes ().contains ("Arduino" )
1214+ if (! lib .getTypes (). isEmpty () && lib .getTypes ().contains ("Arduino" )
12181215 && lib .getArchitectures ().contains ("*" )) {
12191216 ideLibs .add (lib );
12201217 } else {
Original file line number Diff line number Diff line change @@ -204,11 +204,11 @@ private void scanLibrary(UserLibraryFolder folderDesc) throws IOException {
204204 }
205205 }
206206
207- if (lib .getTypes () == null && folderDesc . location == Location .SKETCHBOOK ) {
207+ if (lib .getTypes (). isEmpty () && loc == Location .SKETCHBOOK ) {
208208 lib .setTypes (lib .getDeclaredTypes ());
209209 }
210210
211- if (lib .getTypes () == null ) {
211+ if (lib .getTypes (). isEmpty () ) {
212212 lib .setTypes (Collections .singletonList ("Contributed" ));
213213 }
214214 }
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public TypePredicate(String type) {
4343
4444 @ Override
4545 public boolean test (UserLibrary input ) {
46- return input .getTypes () != null && input . getTypes () .contains (type );
46+ return input .getTypes ().contains (type );
4747 }
4848
4949}
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public class UserLibrary {
5656 private String category ;
5757 private String license ;
5858 private List <String > architectures ;
59- private List <String > types ;
59+ private List <String > types = new ArrayList <>() ;
6060 private List <String > declaredTypes ;
6161 private boolean onGoingDevelopment ;
6262 private List <String > includes ;
You can’t perform that action at this time.
0 commit comments