Skip to content

Commit 76ee5dc

Browse files
committed
Combine if's
1 parent 4aa3d71 commit 76ee5dc

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

plugin/src/main/java/io/jenkins/plugins/casc/impl/configurators/DescriptorConfigurator.java

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,24 +84,24 @@ private Class<?> extractDescriptorTypeParameter(Class<?> clazz) {
8484
while (clazz != null && clazz != Object.class) {
8585
Type genericSuperclass = clazz.getGenericSuperclass();
8686

87-
if (genericSuperclass instanceof ParameterizedType pt) {
88-
Type rawType = pt.getRawType();
89-
90-
if (rawType instanceof Class && Descriptor.class.isAssignableFrom((Class<?>) rawType)) {
91-
Type[] args = pt.getActualTypeArguments();
92-
93-
if (args.length > 0) {
94-
Type typeArg = args[0];
95-
96-
if (typeArg instanceof Class) {
97-
return (Class<?>) typeArg;
98-
} else if (typeArg instanceof ParameterizedType) {
99-
Type nestedRawType = ((ParameterizedType) typeArg).getRawType();
100-
if (nestedRawType instanceof Class) {
101-
return (Class<?>) nestedRawType;
102-
}
103-
}
104-
}
87+
if (genericSuperclass instanceof ParameterizedType pt
88+
&& pt.getRawType() instanceof Class<?> rawClass
89+
&& Descriptor.class.isAssignableFrom(rawClass)) {
90+
91+
Type[] args = pt.getActualTypeArguments();
92+
if (args.length == 0) {
93+
return null;
94+
}
95+
96+
Type typeArg = args[0];
97+
98+
if (typeArg instanceof Class<?> clazzArg) {
99+
return clazzArg;
100+
}
101+
102+
if (typeArg instanceof ParameterizedType nestedPt
103+
&& nestedPt.getRawType() instanceof Class<?> nestedClass) {
104+
return nestedClass;
105105
}
106106
}
107107
clazz = clazz.getSuperclass();

0 commit comments

Comments
 (0)