File tree 6 files changed +18
-14
lines changed
cc/arduino/contributions/libraries
cc/arduino/contributions/libraries
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) {
47
47
48
48
@ Override
49
49
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 ()) {
51
54
return 1 ;
52
55
}
53
- if (o2 .getTypes () == null ) {
56
+ if (o2 .getTypes (). isEmpty () ) {
54
57
return -1 ;
55
58
}
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 ));
57
61
}
58
62
59
63
}
Original file line number Diff line number Diff line change @@ -37,10 +37,13 @@ public class LibraryOfSameTypeComparator implements Comparator<UserLibrary> {
37
37
38
38
@ Override
39
39
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 ()) {
41
44
return 1 ;
42
45
}
43
- if (o2 .getTypes () == null ) {
46
+ if (o2 .getTypes (). isEmpty () ) {
44
47
return -1 ;
45
48
}
46
49
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) {
1193
1193
if (location == Location .IDE_BUILTIN ) {
1194
1194
if (compatible ) {
1195
1195
// 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" )) {
1200
1197
retiredIdeLibs .add (lib );
1201
1198
} else {
1202
1199
ideLibs .add (lib );
@@ -1214,7 +1211,7 @@ public void rebuildExamplesMenu(JMenu menu) {
1214
1211
} else if (location == Location .SKETCHBOOK ) {
1215
1212
if (compatible ) {
1216
1213
// 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" )
1218
1215
&& lib .getArchitectures ().contains ("*" )) {
1219
1216
ideLibs .add (lib );
1220
1217
} else {
Original file line number Diff line number Diff line change @@ -204,11 +204,11 @@ private void scanLibrary(UserLibraryFolder folderDesc) throws IOException {
204
204
}
205
205
}
206
206
207
- if (lib .getTypes () == null && folderDesc . location == Location .SKETCHBOOK ) {
207
+ if (lib .getTypes (). isEmpty () && loc == Location .SKETCHBOOK ) {
208
208
lib .setTypes (lib .getDeclaredTypes ());
209
209
}
210
210
211
- if (lib .getTypes () == null ) {
211
+ if (lib .getTypes (). isEmpty () ) {
212
212
lib .setTypes (Collections .singletonList ("Contributed" ));
213
213
}
214
214
}
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ public TypePredicate(String type) {
43
43
44
44
@ Override
45
45
public boolean test (UserLibrary input ) {
46
- return input .getTypes () != null && input . getTypes () .contains (type );
46
+ return input .getTypes ().contains (type );
47
47
}
48
48
49
49
}
Original file line number Diff line number Diff line change @@ -56,7 +56,7 @@ public class UserLibrary {
56
56
private String category ;
57
57
private String license ;
58
58
private List <String > architectures ;
59
- private List <String > types ;
59
+ private List <String > types = new ArrayList <>() ;
60
60
private List <String > declaredTypes ;
61
61
private boolean onGoingDevelopment ;
62
62
private List <String > includes ;
You can’t perform that action at this time.
0 commit comments