Skip to content

Commit 33d0793

Browse files
authored
Merge pull request #1455 from hazendaz/master
Minor styling cleanup
2 parents da5f6b4 + 25a0609 commit 33d0793

File tree

10 files changed

+56
-77
lines changed

10 files changed

+56
-77
lines changed

pom.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,14 @@
131131
</distributionManagement>
132132

133133
<properties>
134+
<clirr.comparisonVersion>3.4.6</clirr.comparisonVersion>
135+
<excludedGroups>EmbeddedPostgresqlTests</excludedGroups>
134136
<maven.compiler.testCompilerArgument>-parameters</maven.compiler.testCompilerArgument>
135-
<clirr.comparisonVersion>3.3.1</clirr.comparisonVersion>
136-
<spotbugs.onlyAnalyze>org.apache.ibatis.*</spotbugs.onlyAnalyze>
137+
<module.name>org.mybatis</module.name>
137138
<osgi.export>org.apache.ibatis.*;version=${project.version};-noimport:=true</osgi.export>
138139
<osgi.import>*;resolution:=optional</osgi.import>
139140
<osgi.dynamicImport>*</osgi.dynamicImport>
140-
<excludedGroups>EmbeddedPostgresqlTests</excludedGroups>
141-
<module.name>org.mybatis</module.name>
141+
<spotbugs.onlyAnalyze>org.apache.ibatis.*</spotbugs.onlyAnalyze>
142142
</properties>
143143

144144
<dependencies>

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

Lines changed: 13 additions & 10 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
@@ -55,7 +58,7 @@ public Object execute(SqlSession sqlSession, Object[] args) {
5558
Object result;
5659
switch (command.getType()) {
5760
case INSERT: {
58-
Object param = method.convertArgsToSqlCommandParam(args);
61+
Object param = method.convertArgsToSqlCommandParam(args);
5962
result = rowCountResult(sqlSession.insert(command.getName(), param));
6063
break;
6164
}
@@ -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();

src/main/java/org/apache/ibatis/reflection/MetaObject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2009-2018 the original author or authors.
2+
* Copyright 2009-2019 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.
@@ -74,7 +74,7 @@ public ObjectWrapperFactory getObjectWrapperFactory() {
7474
}
7575

7676
public ReflectorFactory getReflectorFactory() {
77-
return reflectorFactory;
77+
return reflectorFactory;
7878
}
7979

8080
public Object getOriginalObject() {

src/main/java/org/apache/ibatis/session/Configuration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,11 +491,11 @@ public MapperRegistry getMapperRegistry() {
491491
}
492492

493493
public ReflectorFactory getReflectorFactory() {
494-
return reflectorFactory;
494+
return reflectorFactory;
495495
}
496496

497497
public void setReflectorFactory(ReflectorFactory reflectorFactory) {
498-
this.reflectorFactory = reflectorFactory;
498+
this.reflectorFactory = reflectorFactory;
499499
}
500500

501501
public ObjectFactory getObjectFactory() {

travis/after_success.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
#
3-
# Copyright 2009-2018 the original author or authors.
3+
# Copyright 2009-2019 the original author or authors.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@ if [ $TRAVIS_REPO_SLUG == "mybatis/mybatis-3" ] && [ "$TRAVIS_PULL_REQUEST" == "
4343
echo -e "Successfully ran coveralls under Travis job ${TRAVIS_JOB_NUMBER}"
4444

4545
# Deploy to site
46-
# Cannot currently run site this way
46+
# Cannot currently run site this way
4747
# ./mvnw site site:deploy -q --settings ./travis/settings.xml
4848
# echo -e "Successfully deploy site under Travis job ${TRAVIS_JOB_NUMBER}"
4949

0 commit comments

Comments
 (0)