Skip to content

Commit 25a0609

Browse files
committed
[ci] Cleanup some checkstyle issues
1 parent 7798e3e commit 25a0609

File tree

6 files changed

+45
-66
lines changed

6 files changed

+45
-66
lines changed

src/main/java/org/apache/ibatis/binding/MapperMethod.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,15 @@
1515
*/
1616
package org.apache.ibatis.binding;
1717

18+
import java.lang.reflect.Array;
19+
import java.lang.reflect.Method;
20+
import java.lang.reflect.ParameterizedType;
21+
import java.lang.reflect.Type;
22+
import java.util.HashMap;
23+
import java.util.List;
24+
import java.util.Map;
25+
import java.util.Optional;
26+
1827
import org.apache.ibatis.annotations.Flush;
1928
import org.apache.ibatis.annotations.MapKey;
2029
import org.apache.ibatis.cursor.Cursor;
@@ -29,12 +38,6 @@
2938
import org.apache.ibatis.session.RowBounds;
3039
import org.apache.ibatis.session.SqlSession;
3140

32-
import java.lang.reflect.Array;
33-
import java.lang.reflect.Method;
34-
import java.lang.reflect.ParameterizedType;
35-
import java.lang.reflect.Type;
36-
import java.util.*;
37-
3841
/**
3942
* @author Clinton Begin
4043
* @author Eduardo Macarron
@@ -82,8 +85,8 @@ public Object execute(SqlSession sqlSession, Object[] args) {
8285
} else {
8386
Object param = method.convertArgsToSqlCommandParam(args);
8487
result = sqlSession.selectOne(command.getName(), param);
85-
if (method.returnsOptional() &&
86-
(result == null || !method.getReturnType().equals(result.getClass()))) {
88+
if (method.returnsOptional()
89+
&& (result == null || !method.getReturnType().equals(result.getClass()))) {
8790
result = Optional.ofNullable(result);
8891
}
8992
}
@@ -224,7 +227,7 @@ public SqlCommand(Configuration configuration, Class<?> mapperInterface, Method
224227
MappedStatement ms = resolveMappedStatement(mapperInterface, methodName, declaringClass,
225228
configuration);
226229
if (ms == null) {
227-
if(method.getAnnotation(Flush.class) != null){
230+
if (method.getAnnotation(Flush.class) != null) {
228231
name = null;
229232
type = SqlCommandType.FLUSH;
230233
} else {

src/main/java/org/apache/ibatis/binding/MapperRegistry.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
*/
1616
package org.apache.ibatis.binding;
1717

18-
import org.apache.ibatis.builder.annotation.MapperAnnotationBuilder;
19-
import org.apache.ibatis.io.ResolverUtil;
20-
import org.apache.ibatis.session.Configuration;
21-
import org.apache.ibatis.session.SqlSession;
22-
2318
import java.util.Collection;
2419
import java.util.Collections;
2520
import java.util.HashMap;
2621
import java.util.Map;
2722
import java.util.Set;
2823

24+
import org.apache.ibatis.builder.annotation.MapperAnnotationBuilder;
25+
import org.apache.ibatis.io.ResolverUtil;
26+
import org.apache.ibatis.session.Configuration;
27+
import org.apache.ibatis.session.SqlSession;
28+
2929
/**
3030
* @author Clinton Begin
3131
* @author Eduardo Macarron

src/main/java/org/apache/ibatis/builder/BaseBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ protected TypeHandler<?> resolveTypeHandler(Class<?> javaType, String typeHandle
127127
if (type != null && !TypeHandler.class.isAssignableFrom(type)) {
128128
throw new BuilderException("Type " + type.getName() + " is not a valid TypeHandler because it does not implement TypeHandler interface");
129129
}
130-
@SuppressWarnings( "unchecked" ) // already verified it is a TypeHandler
130+
@SuppressWarnings("unchecked") // already verified it is a TypeHandler
131131
Class<? extends TypeHandler<?>> typeHandlerType = (Class<? extends TypeHandler<?>>) type;
132132
return resolveTypeHandler(javaType, typeHandlerType);
133133
}

src/main/java/org/apache/ibatis/builder/MapperBuilderAssistant.java

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,13 @@ private Class<?> resolveParameterJavaType(Class<?> resultType, String property,
454454
return javaType;
455455
}
456456

457-
/** Backward compatibility signature */
458-
public ResultMapping buildResultMapping(
459-
Class<?> resultType,
460-
String property,
461-
String column,
462-
Class<?> javaType,
463-
JdbcType jdbcType,
464-
String nestedSelect,
465-
String nestedResultMap,
466-
String notNullColumn,
467-
String columnPrefix,
468-
Class<? extends TypeHandler<?>> typeHandler,
469-
List<ResultFlag> flags) {
470-
return buildResultMapping(
471-
resultType, property, column, javaType, jdbcType, nestedSelect,
472-
nestedResultMap, notNullColumn, columnPrefix, typeHandler, flags, null, null, configuration.isLazyLoadingEnabled());
457+
/** Backward compatibility signature. */
458+
public ResultMapping buildResultMapping(Class<?> resultType, String property, String column, Class<?> javaType,
459+
JdbcType jdbcType, String nestedSelect, String nestedResultMap, String notNullColumn, String columnPrefix,
460+
Class<? extends TypeHandler<?>> typeHandler, List<ResultFlag> flags) {
461+
return buildResultMapping(
462+
resultType, property, column, javaType, jdbcType, nestedSelect,
463+
nestedResultMap, notNullColumn, columnPrefix, typeHandler, flags, null, null, configuration.isLazyLoadingEnabled());
473464
}
474465

475466
public LanguageDriver getLanguageDriver(Class<? extends LanguageDriver> langClass) {
@@ -481,27 +472,12 @@ public LanguageDriver getLanguageDriver(Class<? extends LanguageDriver> langClas
481472
return configuration.getLanguageRegistry().getDriver(langClass);
482473
}
483474

484-
/** Backward compatibility signature */
485-
public MappedStatement addMappedStatement(
486-
String id,
487-
SqlSource sqlSource,
488-
StatementType statementType,
489-
SqlCommandType sqlCommandType,
490-
Integer fetchSize,
491-
Integer timeout,
492-
String parameterMap,
493-
Class<?> parameterType,
494-
String resultMap,
495-
Class<?> resultType,
496-
ResultSetType resultSetType,
497-
boolean flushCache,
498-
boolean useCache,
499-
boolean resultOrdered,
500-
KeyGenerator keyGenerator,
501-
String keyProperty,
502-
String keyColumn,
503-
String databaseId,
504-
LanguageDriver lang) {
475+
/** Backward compatibility signature. */
476+
public MappedStatement addMappedStatement(String id, SqlSource sqlSource, StatementType statementType,
477+
SqlCommandType sqlCommandType, Integer fetchSize, Integer timeout, String parameterMap, Class<?> parameterType,
478+
String resultMap, Class<?> resultType, ResultSetType resultSetType, boolean flushCache, boolean useCache,
479+
boolean resultOrdered, KeyGenerator keyGenerator, String keyProperty, String keyColumn, String databaseId,
480+
LanguageDriver lang) {
505481
return addMappedStatement(
506482
id, sqlSource, statementType, sqlCommandType, fetchSize, timeout,
507483
parameterMap, parameterType, resultMap, resultType, resultSetType,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,15 @@ private Class<?> getReturnType(Method method) {
450450
} else if (method.isAnnotationPresent(MapKey.class) && Map.class.isAssignableFrom(rawType)) {
451451
// (gcode issue 504) Do not look into Maps if there is not MapKey annotation
452452
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
453-
if (actualTypeArguments != null && actualTypeArguments.length == 2) {
454-
Type returnTypeParameter = actualTypeArguments[1];
455-
if (returnTypeParameter instanceof Class<?>) {
456-
returnType = (Class<?>) returnTypeParameter;
457-
} else if (returnTypeParameter instanceof ParameterizedType) {
458-
// (gcode issue 443) actual type can be a also a parameterized type
459-
returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
460-
}
453+
if (actualTypeArguments != null && actualTypeArguments.length == 2) {
454+
Type returnTypeParameter = actualTypeArguments[1];
455+
if (returnTypeParameter instanceof Class<?>) {
456+
returnType = (Class<?>) returnTypeParameter;
457+
} else if (returnTypeParameter instanceof ParameterizedType) {
458+
// (gcode issue 443) actual type can be a also a parameterized type
459+
returnType = (Class<?>) ((ParameterizedType) returnTypeParameter).getRawType();
461460
}
461+
}
462462
} else if (Optional.class.equals(rawType)) {
463463
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
464464
Type returnTypeParameter = actualTypeArguments[0];

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public ProviderSqlSource(Configuration configuration, Object provider, Class<?>
6464

6565
for (Method m : this.providerType.getMethods()) {
6666
if (providerMethodName.equals(m.getName()) && CharSequence.class.isAssignableFrom(m.getReturnType())) {
67-
if (providerMethod != null){
67+
if (providerMethod != null) {
6868
throw new BuilderException("Error creating SqlSource for SqlProvider. Method '"
6969
+ providerMethodName + "' is found multiple in SqlProvider '" + this.providerType.getName()
7070
+ "'. Sql provider method can not overload.");
@@ -83,10 +83,10 @@ public ProviderSqlSource(Configuration configuration, Object provider, Class<?>
8383
throw new BuilderException("Error creating SqlSource for SqlProvider. Method '"
8484
+ providerMethodName + "' not found in SqlProvider '" + this.providerType.getName() + "'.");
8585
}
86-
for (int i = 0; i< this.providerMethodParameterTypes.length; i++) {
86+
for (int i = 0; i < this.providerMethodParameterTypes.length; i++) {
8787
Class<?> parameterType = this.providerMethodParameterTypes[i];
8888
if (parameterType == ProviderContext.class) {
89-
if (this.providerContext != null){
89+
if (this.providerContext != null) {
9090
throw new BuilderException("Error creating SqlSource for SqlProvider. ProviderContext found multiple in SqlProvider method ("
9191
+ this.providerType.getName() + "." + providerMethod.getName()
9292
+ "). ProviderContext can not define multiple in SqlProvider method argument.");
@@ -111,8 +111,8 @@ private SqlSource createSqlSource(Object parameterObject) {
111111
sql = invokeProviderMethod();
112112
} else if (bindParameterCount == 0) {
113113
sql = invokeProviderMethod(providerContext);
114-
} else if (bindParameterCount == 1 &&
115-
(parameterObject == null || providerMethodParameterTypes[providerContextIndex == null || providerContextIndex == 1 ? 0 : 1].isAssignableFrom(parameterObject.getClass()))) {
114+
} else if (bindParameterCount == 1
115+
&& (parameterObject == null || providerMethodParameterTypes[providerContextIndex == null || providerContextIndex == 1 ? 0 : 1].isAssignableFrom(parameterObject.getClass()))) {
116116
sql = invokeProviderMethod(extractProviderMethodArguments(parameterObject));
117117
} else if (parameterObject instanceof Map) {
118118
@SuppressWarnings("unchecked")
@@ -122,7 +122,7 @@ private SqlSource createSqlSource(Object parameterObject) {
122122
throw new BuilderException("Error invoking SqlProvider method ("
123123
+ providerType.getName() + "." + providerMethod.getName()
124124
+ "). Cannot invoke a method that holds "
125-
+ (bindParameterCount == 1 ? "named argument(@Param)": "multiple arguments")
125+
+ (bindParameterCount == 1 ? "named argument(@Param)" : "multiple arguments")
126126
+ " using a specifying parameterObject. In this case, please specify a 'java.util.Map' object.");
127127
}
128128
Class<?> parameterType = parameterObject == null ? Object.class : parameterObject.getClass();

0 commit comments

Comments
 (0)