mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-20 14:54:31 +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
|
@Override
|
||||||
public int compare(UserLibrary o1, UserLibrary o2) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
if (o2.getTypes() == null) {
|
if (o2.getTypes().isEmpty()) {
|
||||||
return -1;
|
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
|
@Override
|
||||||
public int compare(UserLibrary o1, UserLibrary o2) {
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
if (o2.getTypes() == null) {
|
if (o2.getTypes().isEmpty()) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (!o1.getTypes().get(0).equals(o2.getTypes().get(0))) {
|
if (!o1.getTypes().get(0).equals(o2.getTypes().get(0))) {
|
||||||
|
@ -1193,10 +1193,7 @@ public class Base {
|
|||||||
if (location == Location.IDE_BUILTIN) {
|
if (location == Location.IDE_BUILTIN) {
|
||||||
if (compatible) {
|
if (compatible) {
|
||||||
// only compatible IDE libs are shown
|
// only compatible IDE libs are shown
|
||||||
boolean retired = false;
|
if (lib.getTypes().contains("Retired")) {
|
||||||
List<String> types = lib.getTypes();
|
|
||||||
if (types != null) retired = types.contains("Retired");
|
|
||||||
if (retired) {
|
|
||||||
retiredIdeLibs.add(lib);
|
retiredIdeLibs.add(lib);
|
||||||
} else {
|
} else {
|
||||||
ideLibs.add(lib);
|
ideLibs.add(lib);
|
||||||
@ -1214,7 +1211,7 @@ public class Base {
|
|||||||
} else if (location == Location.SKETCHBOOK) {
|
} else if (location == Location.SKETCHBOOK) {
|
||||||
if (compatible) {
|
if (compatible) {
|
||||||
// libraries promoted from sketchbook (behave as builtin)
|
// 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("*")) {
|
&& lib.getArchitectures().contains("*")) {
|
||||||
ideLibs.add(lib);
|
ideLibs.add(lib);
|
||||||
} else {
|
} 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());
|
lib.setTypes(lib.getDeclaredTypes());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lib.getTypes() == null) {
|
if (lib.getTypes().isEmpty()) {
|
||||||
lib.setTypes(Collections.singletonList("Contributed"));
|
lib.setTypes(Collections.singletonList("Contributed"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ public class TypePredicate implements Predicate<UserLibrary> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(UserLibrary input) {
|
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 category;
|
||||||
private String license;
|
private String license;
|
||||||
private List<String> architectures;
|
private List<String> architectures;
|
||||||
private List<String> types;
|
private List<String> types = new ArrayList<>();
|
||||||
private List<String> declaredTypes;
|
private List<String> declaredTypes;
|
||||||
private boolean onGoingDevelopment;
|
private boolean onGoingDevelopment;
|
||||||
private List<String> includes;
|
private List<String> includes;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user