fix potential NPEs
All checks were successful
Publish to snapshot maven / build (push) Successful in 14s
All checks were successful
Publish to snapshot maven / build (push) Successful in 14s
This commit is contained in:
parent
e78696e425
commit
ebb333bd02
|
@ -5,14 +5,27 @@ import java.util.Optional;
|
||||||
|
|
||||||
public record Parchment(String version, List<Package> packages, List<Class> classes) {
|
public record Parchment(String version, List<Package> packages, List<Class> classes) {
|
||||||
public Optional<Class> getClass(String name) {
|
public Optional<Class> getClass(String name) {
|
||||||
|
if (classes == null){
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
return classes.stream().filter(c -> c.name().equals(name)).findFirst();
|
return classes.stream().filter(c -> c.name().equals(name)).findFirst();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Optional<Package> getPackage(String name) {
|
||||||
|
if (packages == null){
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
return packages().stream().filter(p -> p.name().equals(name)).findFirst();
|
||||||
|
}
|
||||||
|
|
||||||
public record Package(String name, List<String> javadoc) {
|
public record Package(String name, List<String> javadoc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public record Class(String name, List<String> javadoc, List<Field> fields, List<Method> methods) {
|
public record Class(String name, List<String> javadoc, List<Field> fields, List<Method> methods) {
|
||||||
public Optional<Field> getField(String name, String descriptor) {
|
public Optional<Field> getField(String name, String descriptor) {
|
||||||
|
if (fields == null){
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
return fields.stream()
|
return fields.stream()
|
||||||
.filter(f -> f.name.equals(name) &&
|
.filter(f -> f.name.equals(name) &&
|
||||||
f.descriptor.equals(descriptor))
|
f.descriptor.equals(descriptor))
|
||||||
|
@ -20,6 +33,9 @@ public record Parchment(String version, List<Package> packages, List<Class> clas
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Method> getMethod(String name, String descriptor) {
|
public Optional<Method> getMethod(String name, String descriptor) {
|
||||||
|
if (methods == null){
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
return methods.stream()
|
return methods.stream()
|
||||||
.filter(method -> method.name.equals(name) &&
|
.filter(method -> method.name.equals(name) &&
|
||||||
method.descriptor.equals(descriptor))
|
method.descriptor.equals(descriptor))
|
||||||
|
|
Loading…
Reference in a new issue