Skip to content

Commit 0914973

Browse files
committed
One more minor simplification. getActualTypeArguments() always returns an array with one element here, I think.
1 parent 828d283 commit 0914973

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/main/java/org/apache/ibatis/builder/annotation/MapperAnnotationBuilder.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2017 the original author or authors.
2+
* Copyright 2009-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -31,6 +31,7 @@
3131
import java.util.List;
3232
import java.util.Locale;
3333
import java.util.Map;
34+
import java.util.Optional;
3435
import java.util.Properties;
3536
import java.util.Set;
3637

@@ -80,6 +81,7 @@
8081
import org.apache.ibatis.mapping.SqlSource;
8182
import org.apache.ibatis.mapping.StatementType;
8283
import org.apache.ibatis.parsing.PropertyParser;
84+
import org.apache.ibatis.reflection.Jdk;
8385
import org.apache.ibatis.reflection.TypeParameterResolver;
8486
import org.apache.ibatis.scripting.LanguageDriver;
8587
import org.apache.ibatis.session.Configuration;
@@ -447,13 +449,11 @@ private Class<?> getReturnType(Method method) {
447449
returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
448450
}
449451
}
450-
} else if ("java.util.Optional".equals(rawType.getName())) {
452+
} else if (Jdk.optionalExists && Optional.class.equals(rawType)) {
451453
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
452-
if (actualTypeArguments != null && actualTypeArguments.length == 1) {
453-
Type returnTypeParameter = actualTypeArguments[0];
454-
if (returnTypeParameter instanceof Class<?>) {
455-
returnType = (Class<?>) returnTypeParameter;
456-
}
454+
Type returnTypeParameter = actualTypeArguments[0];
455+
if (returnTypeParameter instanceof Class<?>) {
456+
returnType = (Class<?>) returnTypeParameter;
457457
}
458458
}
459459
}

0 commit comments

Comments
 (0)