From 65303377ca57b28cd0709f068df67889ab7bee53 Mon Sep 17 00:00:00 2001 From: Knut Wannheden Date: Thu, 5 Dec 2024 08:34:22 +0100 Subject: [PATCH] Added a few missing `@Nullable` annotations to `JavaType` --- .../org/openrewrite/java/tree/JavaType.java | 95 ++++++++++--------- 1 file changed, 49 insertions(+), 46 deletions(-) diff --git a/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java b/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java index 112861469e8..2fa596187f4 100644 --- a/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java +++ b/rewrite-java/src/main/java/org/openrewrite/java/tree/JavaType.java @@ -15,7 +15,10 @@ */ package org.openrewrite.java.tree; -import com.fasterxml.jackson.annotation.*; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIdentityInfo; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.ObjectIdGenerators; import lombok.AccessLevel; import lombok.Getter; import lombok.With; @@ -102,7 +105,7 @@ public MultiCatch(@Nullable List throwableTypes) { this.throwableTypes = arrayOrNullIfEmpty(throwableTypes, EMPTY_JAVA_TYPE_ARRAY); } - MultiCatch(JavaType @Nullable[] throwableTypes) { + MultiCatch(JavaType @Nullable [] throwableTypes) { this.throwableTypes = nullIfEmpty(throwableTypes); } @@ -110,7 +113,7 @@ public MultiCatch(@Nullable List throwableTypes) { MultiCatch() { } - private JavaType[] throwableTypes; + private JavaType @Nullable [] throwableTypes; public List getThrowableTypes() { if (throwableTypes == null) { @@ -143,7 +146,7 @@ public Intersection(@Nullable List bounds) { this.bounds = arrayOrNullIfEmpty(bounds, EMPTY_JAVA_TYPE_ARRAY); } - Intersection(JavaType @Nullable[] throwableTypes) { + Intersection(JavaType @Nullable [] throwableTypes) { this.bounds = nullIfEmpty(throwableTypes); } @@ -151,7 +154,7 @@ public Intersection(@Nullable List bounds) { Intersection() { } - private JavaType[] bounds; + private JavaType @Nullable [] bounds; public List getBounds() { if (bounds == null) { @@ -320,16 +323,16 @@ public String getPackageName() { public boolean isAssignableTo(String fullyQualifiedName) { return TypeUtils.fullyQualifiedNamesAreEqual(getFullyQualifiedName(), fullyQualifiedName) || - getInterfaces().stream().anyMatch(anInterface -> anInterface.isAssignableTo(fullyQualifiedName)) || - (getSupertype() != null && getSupertype().isAssignableTo(fullyQualifiedName)); + getInterfaces().stream().anyMatch(anInterface -> anInterface.isAssignableTo(fullyQualifiedName)) || + (getSupertype() != null && getSupertype().isAssignableTo(fullyQualifiedName)); } public boolean isAssignableFrom(@Nullable JavaType type) { if (type instanceof FullyQualified) { FullyQualified clazz = (FullyQualified) type; return TypeUtils.fullyQualifiedNamesAreEqual(getFullyQualifiedName(), clazz.getFullyQualifiedName()) || - isAssignableFrom(clazz.getSupertype()) || - clazz.getInterfaces().stream().anyMatch(this::isAssignableFrom); + isAssignableFrom(clazz.getSupertype()) || + clazz.getInterfaces().stream().anyMatch(this::isAssignableFrom); } else if (type instanceof GenericTypeVariable) { GenericTypeVariable generic = (GenericTypeVariable) type; for (JavaType bound : generic.getBounds()) { @@ -372,7 +375,7 @@ class Class extends FullyQualified { Kind kind; @NonFinal - JavaType @Nullable[] typeParameters; + JavaType @Nullable [] typeParameters; @With @Nullable @@ -386,7 +389,7 @@ class Class extends FullyQualified { @NonFinal - FullyQualified @Nullable[] annotations; + FullyQualified @Nullable [] annotations; public Class(@Nullable Integer managedReference, long flagsBitMap, String fullyQualifiedName, Kind kind, @Nullable List typeParameters, @Nullable FullyQualified supertype, @Nullable FullyQualified owningClass, @@ -408,9 +411,9 @@ public Class(@Nullable Integer managedReference, long flagsBitMap, String fullyQ } Class(@Nullable Integer managedReference, long flagsBitMap, String fullyQualifiedName, - Kind kind, JavaType @Nullable[] typeParameters, @Nullable FullyQualified supertype, @Nullable FullyQualified owningClass, - FullyQualified @Nullable[] annotations, FullyQualified @Nullable[] interfaces, - Variable @Nullable[] members, Method @Nullable[] methods) { + Kind kind, JavaType @Nullable [] typeParameters, @Nullable FullyQualified supertype, @Nullable FullyQualified owningClass, + FullyQualified @Nullable [] annotations, FullyQualified @Nullable [] interfaces, + Variable @Nullable [] members, Method @Nullable [] methods) { this.managedReference = managedReference; this.flagsBitMap = flagsBitMap & Flag.VALID_CLASS_FLAGS; this.fullyQualifiedName = fullyQualifiedName; @@ -445,7 +448,7 @@ public Class withAnnotations(@Nullable List annotations) { @NonFinal - FullyQualified @Nullable[] interfaces; + FullyQualified @Nullable [] interfaces; @Override public List getInterfaces() { @@ -463,7 +466,7 @@ public Class withInterfaces(@Nullable List interfaces) { @NonFinal - Variable @Nullable[] members; + Variable @Nullable [] members; @Override public List getMembers() { @@ -481,7 +484,7 @@ public Class withMembers(@Nullable List members) { @NonFinal - Method @Nullable[] methods; + Method @Nullable [] methods; @Override public List getMethods() { @@ -554,9 +557,9 @@ public Class unsafeSet(@Nullable List typeParameters, @Nullable FullyQ return this; } - public Class unsafeSet(JavaType @Nullable[] typeParameters, @Nullable FullyQualified supertype, @Nullable FullyQualified owningClass, - FullyQualified @Nullable[] annotations, FullyQualified @Nullable[] interfaces, - Variable @Nullable[] members, Method @Nullable[] methods) { + public Class unsafeSet(JavaType @Nullable [] typeParameters, @Nullable FullyQualified supertype, @Nullable FullyQualified owningClass, + FullyQualified @Nullable [] annotations, FullyQualified @Nullable [] interfaces, + Variable @Nullable [] members, Method @Nullable [] methods) { //noinspection DuplicatedCode this.typeParameters = ListUtils.nullIfEmpty(typeParameters); this.supertype = supertype; @@ -574,7 +577,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Class aClass = (Class) o; return TypeUtils.fullyQualifiedNamesAreEqual(fullyQualifiedName, aClass.fullyQualifiedName) && - (typeParameters == null && aClass.typeParameters == null || typeParameters != null && Arrays.equals(typeParameters, aClass.typeParameters)); + (typeParameters == null && aClass.typeParameters == null || typeParameters != null && Arrays.equals(typeParameters, aClass.typeParameters)); } @Override @@ -639,7 +642,7 @@ class Parameterized extends FullyQualified { FullyQualified type; @NonFinal - JavaType @Nullable[] typeParameters; + JavaType @Nullable [] typeParameters; public Parameterized(@Nullable Integer managedReference, @Nullable FullyQualified type, @Nullable List typeParameters) { @@ -651,7 +654,7 @@ public Parameterized(@Nullable Integer managedReference, @Nullable FullyQualifie } Parameterized(@Nullable Integer managedReference, @Nullable FullyQualified type, - JavaType @Nullable[] typeParameters) { + JavaType @Nullable [] typeParameters) { this.managedReference = managedReference; this.type = unknownIfNull(type); this.typeParameters = nullIfEmpty(typeParameters); @@ -691,7 +694,7 @@ public Parameterized unsafeSet(@Nullable FullyQualified type, @Nullable List bounds) { this( @@ -802,7 +805,7 @@ public GenericTypeVariable(@Nullable Integer managedReference, String name, Vari ); } - GenericTypeVariable(@Nullable Integer managedReference, String name, Variance variance, JavaType @Nullable[] bounds) { + GenericTypeVariable(@Nullable Integer managedReference, String name, Variance variance, JavaType @Nullable [] bounds) { this.managedReference = managedReference; this.name = name; this.variance = variance; @@ -838,7 +841,7 @@ public GenericTypeVariable unsafeSet(String name, Variance variance, @Nullable L return this; } - public GenericTypeVariable unsafeSet(String name, Variance variance, JavaType @Nullable[] bounds) { + public GenericTypeVariable unsafeSet(String name, Variance variance, JavaType @Nullable [] bounds) { this.name = name; this.variance = variance; this.bounds = ListUtils.nullIfEmpty(bounds); @@ -851,7 +854,7 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; GenericTypeVariable that = (GenericTypeVariable) o; return name.equals(that.name) && variance == that.variance && - (variance == Variance.INVARIANT && bounds == null && that.bounds == null || bounds != null && Arrays.equals(bounds, that.bounds)); + (variance == Variance.INVARIANT && bounds == null && that.bounds == null || bounds != null && Arrays.equals(bounds, that.bounds)); } @Override @@ -879,9 +882,9 @@ class Array implements JavaType { @NonFinal - FullyQualified @Nullable[] annotations; + FullyQualified @Nullable [] annotations; - public Array(@Nullable Integer managedReference, @Nullable JavaType elemType, FullyQualified @Nullable[] annotations) { + public Array(@Nullable Integer managedReference, @Nullable JavaType elemType, FullyQualified @Nullable [] annotations) { this.managedReference = managedReference; this.elemType = unknownIfNull(elemType); this.annotations = ListUtils.nullIfEmpty(annotations); @@ -913,7 +916,7 @@ public Array unsafeSetManagedReference(Integer id) { return this; } - public Array unsafeSet(JavaType elemType, FullyQualified @Nullable[] annotations) { + public Array unsafeSet(JavaType elemType, FullyQualified @Nullable [] annotations) { this.elemType = unknownIfNull(elemType); this.annotations = ListUtils.nullIfEmpty(annotations); return this; @@ -1099,16 +1102,16 @@ class Method implements JavaType { @NonFinal - String @Nullable[] parameterNames; + String @Nullable [] parameterNames; @NonFinal - JavaType @Nullable[] parameterTypes; + JavaType @Nullable [] parameterTypes; @NonFinal - FullyQualified @Nullable[] thrownExceptions; + FullyQualified @Nullable [] thrownExceptions; @NonFinal - FullyQualified @Nullable[] annotations; + FullyQualified @Nullable [] annotations; @Incubating(since = "7.34.0") @Nullable @@ -1142,9 +1145,9 @@ public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable Fu } public Method(@Nullable Integer managedReference, long flagsBitMap, @Nullable FullyQualified declaringType, String name, - @Nullable JavaType returnType, String @Nullable[] parameterNames, - JavaType @Nullable[] parameterTypes, FullyQualified @Nullable[] thrownExceptions, - FullyQualified @Nullable[] annotations, @Nullable List defaultValue) { + @Nullable JavaType returnType, String @Nullable [] parameterNames, + JavaType @Nullable [] parameterTypes, FullyQualified @Nullable [] thrownExceptions, + FullyQualified @Nullable [] annotations, @Nullable List defaultValue) { this.managedReference = managedReference; this.flagsBitMap = flagsBitMap & Flag.VALID_FLAGS; this.declaringType = unknownIfNull(declaringType); @@ -1182,9 +1185,9 @@ public Method unsafeSet(@Nullable FullyQualified declaringType, public Method unsafeSet(@Nullable FullyQualified declaringType, @Nullable JavaType returnType, - JavaType @Nullable[] parameterTypes, - FullyQualified @Nullable[] thrownExceptions, - FullyQualified @Nullable[] annotations) { + JavaType @Nullable [] parameterTypes, + FullyQualified @Nullable [] thrownExceptions, + FullyQualified @Nullable [] annotations) { this.declaringType = unknownIfNull(declaringType); this.returnType = unknownIfNull(returnType); this.parameterTypes = ListUtils.nullIfEmpty(parameterTypes); @@ -1355,9 +1358,9 @@ public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Method method = (Method) o; return Objects.equals(declaringType, method.declaringType) && - name.equals(method.name) && - Objects.equals(returnType, method.returnType) && - Arrays.equals(parameterTypes, method.parameterTypes); + name.equals(method.name) && + Objects.equals(returnType, method.returnType) && + Arrays.equals(parameterTypes, method.parameterTypes); } @Override @@ -1393,7 +1396,7 @@ class Variable implements JavaType { JavaType type; @NonFinal - FullyQualified @Nullable[] annotations; + FullyQualified @Nullable [] annotations; public Variable(@Nullable Integer managedReference, long flagsBitMap, String name, @Nullable JavaType owner, @Nullable JavaType type, @Nullable List annotations) { @@ -1408,7 +1411,7 @@ public Variable(@Nullable Integer managedReference, long flagsBitMap, String nam } Variable(@Nullable Integer managedReference, long flagsBitMap, String name, @Nullable JavaType owner, - @Nullable JavaType type, FullyQualified @Nullable[] annotations) { + @Nullable JavaType type, FullyQualified @Nullable [] annotations) { this.managedReference = managedReference; this.flagsBitMap = flagsBitMap & Flag.VALID_FLAGS; this.name = name;