Skip to content

Commit 9120feb

Browse files
committed
perf(hibernate processor): fix nullable things in util package
1 parent 0f85a39 commit 9120feb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/processor/util/TypeRenderingVisitor.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
import org.jspecify.annotations.Nullable;
2828

29+
import static java.util.Objects.requireNonNull;
2930
import static org.hibernate.processor.util.Constants.JAVA_OBJECT;
3031

3132
/**
@@ -45,7 +46,7 @@ public static String toString(TypeMirror typeMirror) {
4546
final Element typeVariableElement = ( (TypeVariable) typeMirror ).asElement();
4647
if ( typeVariableElement instanceof TypeParameterElement ) {
4748
final TypeParameterElement typeParameter = (TypeParameterElement) typeVariableElement;
48-
if ( typeParameter.getEnclosingElement().getKind() == ElementKind.METHOD ) {
49+
if ( requireNonNull( typeParameter.getEnclosingElement() ).getKind() == ElementKind.METHOD ) {
4950
// But for method level type variable we return the upper bound
5051
// because the type variable has no meaning except for that method
5152
typeMirror = ( (TypeVariable) typeMirror ).getUpperBound();
@@ -106,7 +107,7 @@ else if ( typeMirror instanceof IntersectionType ) {
106107
}
107108

108109
@Override
109-
public @Nullable Object visitArray(ArrayType t, @Nullable Object o) {
110+
public Object visitArray(ArrayType t, @Nullable Object o) {
110111
t.getComponentType().accept( this, null );
111112
sb.append( "[]" );
112113
return t;

tooling/metamodel-generator/src/main/java/org/hibernate/processor/util/TypeUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public static String extractClosestRealTypeAsString(TypeMirror type, Context con
163163
}
164164
}
165165

166-
public static @Nullable TypeMirror extractClosestRealType(TypeMirror type, Context context, Set<TypeVariable> beingVisited) {
166+
public static @Nullable TypeMirror extractClosestRealType(@Nullable TypeMirror type, Context context, Set<TypeVariable> beingVisited) {
167167
if ( type == null ) {
168168
return null;
169169
}
@@ -722,7 +722,7 @@ public static String getGeneratedClassFullyQualifiedName(TypeElement typeElement
722722
+ "." + (jakartaDataStyle ? '_' + simpleName : simpleName + '_');
723723
}
724724

725-
private static String qualifiedName(Element enclosingElement, boolean jakartaDataStyle) {
725+
private static String qualifiedName(@Nullable Element enclosingElement, boolean jakartaDataStyle) {
726726
if ( enclosingElement instanceof TypeElement typeElement ) {
727727
return getGeneratedClassFullyQualifiedName( typeElement, jakartaDataStyle );
728728
}

0 commit comments

Comments
 (0)