Skip to content

Commit e2c7d58

Browse files
committed
[ci] formatting
1 parent a0f8d36 commit e2c7d58

33 files changed

+862
-763
lines changed

format.xml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright 2009-2023 the original author or authors.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
https://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
18+
-->
19+
<!DOCTYPE Format>
20+
<Format>
21+
<!-- Dummy format file -->
22+
</Format>

src/main/java/org/apache/ibatis/annotations/SelectProvider.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
* Specify a type that implements an SQL provider method.
6666
* <p>
6767
* This attribute is alias of {@link #value()}.
68-
* </p>
6968
*
7069
* @return a type that implements an SQL provider method
7170
*
@@ -77,18 +76,24 @@
7776
* Specify a method for providing an SQL.
7877
* <p>
7978
* Since 3.5.1, this attribute can omit.
79+
* <p>
8080
* If this attribute omit, the MyBatis will call a method that decide by following rules.
81+
*
82+
* <pre>
8183
* <ul>
8284
* <li>
8385
* If class that specified the {@link #type()} attribute implements the
8486
* {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver},
85-
* the MyBatis use a method that returned by it
87+
* the MyBatis use a method that returned by it.
8688
* </li>
8789
* <li>
88-
* If cannot resolve a method by {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver}(= not implement it or it was returned {@code null}),
89-
* the MyBatis will search and use a fallback method that named {@code provideSql} from specified type
90+
* If cannot resolve a method by {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver}
91+
* (= not implement it or it was returned <code>null</code>,
92+
* the MyBatis will search and use a fallback method that named <code>provideSql</code> from
93+
* specified type.
9094
* </li>
9195
* </ul>
96+
* </pre>
9297
*
9398
* @return a method name of method for providing an SQL
9499
*/

src/main/java/org/apache/ibatis/annotations/TypeDiscriminator.java

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.ibatis.type.TypeHandler;
2626
import org.apache.ibatis.type.UnknownTypeHandler;
2727

28+
// @formatter:off
2829
/**
2930
* The annotation that be grouping conditional mapping definitions.
3031
* <p>
@@ -48,6 +49,7 @@
4849
*
4950
* @author Clinton Begin
5051
*/
52+
// @formatter:on
5153
@Documented
5254
@Retention(RetentionPolicy.RUNTIME)
5355
@Target(ElementType.METHOD)

src/main/java/org/apache/ibatis/annotations/UpdateProvider.java

+6-2
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,21 @@
7878
* <p>
7979
* Since 3.5.1, this attribute can omit. If this attribute omit, the MyBatis will call a method that decide by
8080
* following rules.
81+
*
82+
* <pre>
8183
* <ul>
8284
* <li>
8385
* If class that specified the {@link #type()} attribute implements the
8486
* {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver},
8587
* the MyBatis use a method that returned by it
8688
* </li>
8789
* <li>
88-
* If cannot resolve a method by {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver}(= not implement it or it was returned {@code null}),
89-
* the MyBatis will search and use a fallback method that named {@code provideSql} from specified type
90+
* If cannot resolve a method by {@link org.apache.ibatis.builder.annotation.ProviderMethodResolver}
91+
* (= not implement it or it was returned <code>null</code>,
92+
* the MyBatis will search and use a fallback method that named <code>provideSql</code> from specified type
9093
* </li>
9194
* </ul>
95+
* </pre>
9296
*
9397
* @return a method name of method for providing an SQL
9498
*/

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

+30-111
Original file line numberDiff line numberDiff line change
@@ -121,22 +121,11 @@ public Cache useCacheRef(String namespace) {
121121
}
122122
}
123123

124-
public Cache useNewCache(Class<? extends Cache> typeClass,
125-
Class<? extends Cache> evictionClass,
126-
Long flushInterval,
127-
Integer size,
128-
boolean readWrite,
129-
boolean blocking,
130-
Properties props) {
131-
Cache cache = new CacheBuilder(currentNamespace)
132-
.implementation(valueOrDefault(typeClass, PerpetualCache.class))
133-
.addDecorator(valueOrDefault(evictionClass, LruCache.class))
134-
.clearInterval(flushInterval)
135-
.size(size)
136-
.readWrite(readWrite)
137-
.blocking(blocking)
138-
.properties(props)
139-
.build();
124+
public Cache useNewCache(Class<? extends Cache> typeClass, Class<? extends Cache> evictionClass, Long flushInterval,
125+
Integer size, boolean readWrite, boolean blocking, Properties props) {
126+
Cache cache = new CacheBuilder(currentNamespace).implementation(valueOrDefault(typeClass, PerpetualCache.class))
127+
.addDecorator(valueOrDefault(evictionClass, LruCache.class)).clearInterval(flushInterval).size(size)
128+
.readWrite(readWrite).blocking(blocking).properties(props).build();
140129
configuration.addCache(cache);
141130
currentCache = cache;
142131
return cache;
@@ -149,37 +138,21 @@ public ParameterMap addParameterMap(String id, Class<?> parameterClass, List<Par
149138
return parameterMap;
150139
}
151140

152-
public ParameterMapping buildParameterMapping(
153-
Class<?> parameterType,
154-
String property,
155-
Class<?> javaType,
156-
JdbcType jdbcType,
157-
String resultMap,
158-
ParameterMode parameterMode,
159-
Class<? extends TypeHandler<?>> typeHandler,
141+
public ParameterMapping buildParameterMapping(Class<?> parameterType, String property, Class<?> javaType,
142+
JdbcType jdbcType, String resultMap, ParameterMode parameterMode, Class<? extends TypeHandler<?>> typeHandler,
160143
Integer numericScale) {
161144
resultMap = applyCurrentNamespace(resultMap, true);
162145

163146
// Class parameterType = parameterMapBuilder.type();
164147
Class<?> javaTypeClass = resolveParameterJavaType(parameterType, property, javaType, jdbcType);
165148
TypeHandler<?> typeHandlerInstance = resolveTypeHandler(javaTypeClass, typeHandler);
166149

167-
return new ParameterMapping.Builder(configuration, property, javaTypeClass)
168-
.jdbcType(jdbcType)
169-
.resultMapId(resultMap)
170-
.mode(parameterMode)
171-
.numericScale(numericScale)
172-
.typeHandler(typeHandlerInstance)
173-
.build();
150+
return new ParameterMapping.Builder(configuration, property, javaTypeClass).jdbcType(jdbcType)
151+
.resultMapId(resultMap).mode(parameterMode).numericScale(numericScale).typeHandler(typeHandlerInstance).build();
174152
}
175153

176-
public ResultMap addResultMap(
177-
String id,
178-
Class<?> type,
179-
String extend,
180-
Discriminator discriminator,
181-
List<ResultMapping> resultMappings,
182-
Boolean autoMapping) {
154+
public ResultMap addResultMap(String id, Class<?> type, String extend, Discriminator discriminator,
155+
List<ResultMapping> resultMappings, Boolean autoMapping) {
183156
id = applyCurrentNamespace(id, false);
184157
extend = applyCurrentNamespace(extend, true);
185158

@@ -209,28 +182,10 @@ public ResultMap addResultMap(
209182
return resultMap;
210183
}
211184

212-
public Discriminator buildDiscriminator(
213-
Class<?> resultType,
214-
String column,
215-
Class<?> javaType,
216-
JdbcType jdbcType,
217-
Class<? extends TypeHandler<?>> typeHandler,
218-
Map<String, String> discriminatorMap) {
219-
ResultMapping resultMapping = buildResultMapping(
220-
resultType,
221-
null,
222-
column,
223-
javaType,
224-
jdbcType,
225-
null,
226-
null,
227-
null,
228-
null,
229-
typeHandler,
230-
new ArrayList<>(),
231-
null,
232-
null,
233-
false);
185+
public Discriminator buildDiscriminator(Class<?> resultType, String column, Class<?> javaType, JdbcType jdbcType,
186+
Class<? extends TypeHandler<?>> typeHandler, Map<String, String> discriminatorMap) {
187+
ResultMapping resultMapping = buildResultMapping(resultType, null, column, javaType, jdbcType, null, null, null,
188+
null, typeHandler, new ArrayList<>(), null, null, false);
234189
Map<String, String> namespaceDiscriminatorMap = new HashMap<>();
235190
for (Map.Entry<String, String> e : discriminatorMap.entrySet()) {
236191
String resultMap = e.getValue();
@@ -240,28 +195,11 @@ public Discriminator buildDiscriminator(
240195
return new Discriminator.Builder(configuration, resultMapping, namespaceDiscriminatorMap).build();
241196
}
242197

243-
public MappedStatement addMappedStatement(
244-
String id,
245-
SqlSource sqlSource,
246-
StatementType statementType,
247-
SqlCommandType sqlCommandType,
248-
Integer fetchSize,
249-
Integer timeout,
250-
String parameterMap,
251-
Class<?> parameterType,
252-
String resultMap,
253-
Class<?> resultType,
254-
ResultSetType resultSetType,
255-
boolean flushCache,
256-
boolean useCache,
257-
boolean resultOrdered,
258-
KeyGenerator keyGenerator,
259-
String keyProperty,
260-
String keyColumn,
261-
String databaseId,
262-
LanguageDriver lang,
263-
String resultSets,
264-
boolean dirtySelect) {
198+
public MappedStatement addMappedStatement(String id, SqlSource sqlSource, StatementType statementType,
199+
SqlCommandType sqlCommandType, Integer fetchSize, Integer timeout, String parameterMap, Class<?> parameterType,
200+
String resultMap, Class<?> resultType, ResultSetType resultSetType, boolean flushCache, boolean useCache,
201+
boolean resultOrdered, KeyGenerator keyGenerator, String keyProperty, String keyColumn, String databaseId,
202+
LanguageDriver lang, String resultSets, boolean dirtySelect) {
265203

266204
if (unresolvedCacheRef) {
267205
throw new IncompleteElementException("Cache-ref not yet resolved");
@@ -270,23 +208,11 @@ public MappedStatement addMappedStatement(
270208
id = applyCurrentNamespace(id, false);
271209

272210
MappedStatement.Builder statementBuilder = new MappedStatement.Builder(configuration, id, sqlSource, sqlCommandType)
273-
.resource(resource)
274-
.fetchSize(fetchSize)
275-
.timeout(timeout)
276-
.statementType(statementType)
277-
.keyGenerator(keyGenerator)
278-
.keyProperty(keyProperty)
279-
.keyColumn(keyColumn)
280-
.databaseId(databaseId)
281-
.lang(lang)
282-
.resultOrdered(resultOrdered)
283-
.resultSets(resultSets)
284-
.resultMaps(getStatementResultMaps(resultMap, resultType, id))
285-
.resultSetType(resultSetType)
286-
.flushCacheRequired(flushCache)
287-
.useCache(useCache)
288-
.cache(currentCache)
289-
.dirtySelect(dirtySelect);
211+
.resource(resource).fetchSize(fetchSize).timeout(timeout).statementType(statementType)
212+
.keyGenerator(keyGenerator).keyProperty(keyProperty).keyColumn(keyColumn).databaseId(databaseId).lang(lang)
213+
.resultOrdered(resultOrdered).resultSets(resultSets)
214+
.resultMaps(getStatementResultMaps(resultMap, resultType, id)).resultSetType(resultSetType)
215+
.flushCacheRequired(flushCache).useCache(useCache).cache(currentCache).dirtySelect(dirtySelect);
290216

291217
ParameterMap statementParameterMap = getStatementParameterMap(parameterMap, parameterType, id);
292218
if (statementParameterMap != null) {
@@ -418,19 +344,12 @@ public ResultMapping buildResultMapping(Class<?> resultType, String property, St
418344
} else {
419345
composites = parseCompositeColumnName(column);
420346
}
421-
return new ResultMapping.Builder(configuration, property, column, javaTypeClass)
422-
.jdbcType(jdbcType)
347+
return new ResultMapping.Builder(configuration, property, column, javaTypeClass).jdbcType(jdbcType)
423348
.nestedQueryId(applyCurrentNamespace(nestedSelect, true))
424-
.nestedResultMapId(applyCurrentNamespace(nestedResultMap, true))
425-
.resultSet(resultSet)
426-
.typeHandler(typeHandlerInstance)
427-
.flags(flags == null ? new ArrayList<>() : flags)
428-
.composites(composites)
429-
.notNullColumns(parseMultipleColumnNames(notNullColumn))
430-
.columnPrefix(columnPrefix)
431-
.foreignColumn(foreignColumn)
432-
.lazy(lazy)
433-
.build();
349+
.nestedResultMapId(applyCurrentNamespace(nestedResultMap, true)).resultSet(resultSet)
350+
.typeHandler(typeHandlerInstance).flags(flags == null ? new ArrayList<>() : flags).composites(composites)
351+
.notNullColumns(parseMultipleColumnNames(notNullColumn)).columnPrefix(columnPrefix).foreignColumn(foreignColumn)
352+
.lazy(lazy).build();
434353
}
435354

436355
/**

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

+16-54
Original file line numberDiff line numberDiff line change
@@ -362,31 +362,13 @@ void parseStatement(Method method) {
362362
}
363363
}
364364

365-
assistant.addMappedStatement(
366-
mappedStatementId,
367-
sqlSource,
368-
statementType,
369-
sqlCommandType,
370-
fetchSize,
371-
timeout,
365+
assistant.addMappedStatement(mappedStatementId, sqlSource, statementType, sqlCommandType, fetchSize, timeout,
372366
// ParameterMapID
373-
null,
374-
parameterTypeClass,
375-
resultMapId,
376-
getReturnType(method, type),
377-
resultSetType,
378-
flushCache,
379-
useCache,
367+
null, parameterTypeClass, resultMapId, getReturnType(method, type), resultSetType, flushCache, useCache,
380368
// TODO gcode issue #577
381-
false,
382-
keyGenerator,
383-
keyProperty,
384-
keyColumn,
385-
statementAnnotation.getDatabaseId(),
386-
languageDriver,
369+
false, keyGenerator, keyProperty, keyColumn, statementAnnotation.getDatabaseId(), languageDriver,
387370
// ResultSets
388-
options != null ? nullOrEmpty(options.resultSets()) : null,
389-
statementAnnotation.isDirtySelect());
371+
options != null ? nullOrEmpty(options.resultSets()) : null, statementAnnotation.isDirtySelect());
390372
});
391373
}
392374

@@ -480,24 +462,15 @@ private void applyResults(Result[] results, Class<?> resultType, List<ResultMapp
480462
flags.add(ResultFlag.ID);
481463
}
482464
@SuppressWarnings("unchecked")
483-
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
484-
((result.typeHandler() == UnknownTypeHandler.class) ? null : result.typeHandler());
465+
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) ((result
466+
.typeHandler() == UnknownTypeHandler.class) ? null : result.typeHandler());
485467
boolean hasNestedResultMap = hasNestedResultMap(result);
486-
ResultMapping resultMapping = assistant.buildResultMapping(
487-
resultType,
488-
nullOrEmpty(result.property()),
489-
nullOrEmpty(result.column()),
490-
result.javaType() == void.class ? null : result.javaType(),
468+
ResultMapping resultMapping = assistant.buildResultMapping(resultType, nullOrEmpty(result.property()),
469+
nullOrEmpty(result.column()), result.javaType() == void.class ? null : result.javaType(),
491470
result.jdbcType() == JdbcType.UNDEFINED ? null : result.jdbcType(),
492471
hasNestedSelect(result) ? nestedSelectId(result) : null,
493-
hasNestedResultMap ? nestedResultMapId(result) : null,
494-
null,
495-
hasNestedResultMap ? findColumnPrefix(result) : null,
496-
typeHandler,
497-
flags,
498-
null,
499-
null,
500-
isLazy(result));
472+
hasNestedResultMap ? nestedResultMapId(result) : null, null,
473+
hasNestedResultMap ? findColumnPrefix(result) : null, typeHandler, flags, null, null, isLazy(result));
501474
resultMappings.add(resultMapping);
502475
}
503476
}
@@ -564,23 +537,12 @@ private void applyConstructorArgs(Arg[] args, Class<?> resultType, List<ResultMa
564537
flags.add(ResultFlag.ID);
565538
}
566539
@SuppressWarnings("unchecked")
567-
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>)
568-
(arg.typeHandler() == UnknownTypeHandler.class ? null : arg.typeHandler());
569-
ResultMapping resultMapping = assistant.buildResultMapping(
570-
resultType,
571-
nullOrEmpty(arg.name()),
572-
nullOrEmpty(arg.column()),
573-
arg.javaType() == void.class ? null : arg.javaType(),
574-
arg.jdbcType() == JdbcType.UNDEFINED ? null : arg.jdbcType(),
575-
nullOrEmpty(arg.select()),
576-
nullOrEmpty(arg.resultMap()),
577-
null,
578-
nullOrEmpty(arg.columnPrefix()),
579-
typeHandler,
580-
flags,
581-
null,
582-
null,
583-
false);
540+
Class<? extends TypeHandler<?>> typeHandler = (Class<? extends TypeHandler<?>>) (arg
541+
.typeHandler() == UnknownTypeHandler.class ? null : arg.typeHandler());
542+
ResultMapping resultMapping = assistant.buildResultMapping(resultType, nullOrEmpty(arg.name()),
543+
nullOrEmpty(arg.column()), arg.javaType() == void.class ? null : arg.javaType(),
544+
arg.jdbcType() == JdbcType.UNDEFINED ? null : arg.jdbcType(), nullOrEmpty(arg.select()),
545+
nullOrEmpty(arg.resultMap()), null, nullOrEmpty(arg.columnPrefix()), typeHandler, flags, null, null, false);
584546
resultMappings.add(resultMapping);
585547
}
586548
}

0 commit comments

Comments
 (0)