mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-17 11:54:33 +01:00
UserLibrary: ensure that types field is always not-null
This commit is contained in:
parent
20bc297151
commit
ac570c50bd
@ -47,13 +47,17 @@ public class LibraryByTypeComparator implements Comparator<UserLibrary> {
|
||||
|
||||
@Override
|
||||
public int compare(UserLibrary o1, UserLibrary o2) {
|
||||
if (o1.getTypes() == null) {
|
||||
if (o1.getTypes().isEmpty() && o2.getTypes().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (o1.getTypes().isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
if (o2.getTypes() == null) {
|
||||
if (o2.getTypes().isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
return libraryTypeComparator.compare(o1.getTypes().get(0), o2.getTypes().get(0));
|
||||
return libraryTypeComparator.compare(o1.getTypes().get(0),
|
||||
o2.getTypes().get(0));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -37,10 +37,13 @@ public class LibraryOfSameTypeComparator implements Comparator<UserLibrary> {
|
||||
|
||||
@Override
|
||||
public int compare(UserLibrary o1, UserLibrary o2) {
|
||||
if (o1.getTypes() == null) {
|
||||
if (o1.getTypes().isEmpty() && o2.getTypes().isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
if (o1.getTypes().isEmpty()) {
|
||||
return 1;
|
||||
}
|
||||
if (o2.getTypes() == null) {
|
||||
if (o2.getTypes().isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
if (!o1.getTypes().get(0).equals(o2.getTypes().get(0))) {
|
||||
|
@ -1193,10 +1193,7 @@ public class Base {
|
||||
if (location == Location.IDE_BUILTIN) {
|
||||
if (compatible) {
|
||||
// only compatible IDE libs are shown
|
||||
boolean retired = false;
|
||||
List<String> types = lib.getTypes();
|
||||
if (types != null) retired = types.contains("Retired");
|
||||
if (retired) {
|
||||
if (lib.getTypes().contains("Retired")) {
|
||||
retiredIdeLibs.add(lib);
|
||||
} else {
|
||||
ideLibs.add(lib);
|
||||
@ -1214,7 +1211,7 @@ public class Base {
|
||||
} else if (location == Location.SKETCHBOOK) {
|
||||
if (compatible) {
|
||||
// libraries promoted from sketchbook (behave as builtin)
|
||||
if (lib.getTypes() != null && lib.getTypes().contains("Arduino")
|
||||
if (!lib.getTypes().isEmpty() && lib.getTypes().contains("Arduino")
|
||||
&& lib.getArchitectures().contains("*")) {
|
||||
ideLibs.add(lib);
|
||||
} else {
|
||||
|
@ -204,11 +204,11 @@ public class LibrariesIndexer {
|
||||
}
|
||||
}
|
||||
|
||||
if (lib.getTypes() == null && folderDesc.location == Location.SKETCHBOOK) {
|
||||
if (lib.getTypes().isEmpty() && loc == Location.SKETCHBOOK) {
|
||||
lib.setTypes(lib.getDeclaredTypes());
|
||||
}
|
||||
|
||||
if (lib.getTypes() == null) {
|
||||
if (lib.getTypes().isEmpty()) {
|
||||
lib.setTypes(Collections.singletonList("Contributed"));
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public class TypePredicate implements Predicate<UserLibrary> {
|
||||
|
||||
@Override
|
||||
public boolean test(UserLibrary input) {
|
||||
return input.getTypes() != null && input.getTypes().contains(type);
|
||||
return input.getTypes().contains(type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class UserLibrary {
|
||||
private String category;
|
||||
private String license;
|
||||
private List<String> architectures;
|
||||
private List<String> types;
|
||||
private List<String> types = new ArrayList<>();
|
||||
private List<String> declaredTypes;
|
||||
private boolean onGoingDevelopment;
|
||||
private List<String> includes;
|
||||
|
Loading…
x
Reference in New Issue
Block a user