Skip to content

Commit a0f8d36

Browse files
authored
Merge pull request #2797 from hazendaz/formatting
[ci] formatting
2 parents 59afc18 + f859d90 commit a0f8d36

File tree

17 files changed

+135
-103
lines changed

17 files changed

+135
-103
lines changed

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

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.apache.ibatis.cache.decorators.LruCache;
2626
import org.apache.ibatis.cache.impl.PerpetualCache;
2727

28+
// @formatter:off
2829
/**
2930
* The annotation that specify to use cache on namespace(e.g. mapper interface).
3031
* <p>
@@ -44,6 +45,7 @@
4445
* @author Clinton Begin
4546
* @author Kazuki Shimizu
4647
*/
48+
// @formatter:on
4749
@Documented
4850
@Retention(RetentionPolicy.RUNTIME)
4951
@Target(ElementType.TYPE)

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

+2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.lang.annotation.RetentionPolicy;
2222
import java.lang.annotation.Target;
2323

24+
// @formatter:off
2425
/**
2526
* The annotation that be grouping mapping definitions for constructor.
2627
* <p>
@@ -40,6 +41,7 @@
4041
*
4142
* @author Clinton Begin
4243
*/
44+
// @formatter:on
4345
@Documented
4446
@Retention(RetentionPolicy.RUNTIME)
4547
@Target(ElementType.METHOD)

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

+3
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@
7373
*/
7474
Class<?> type() default void.class;
7575

76+
// @formatter:off
7677
/**
7778
* Specify a method for providing an SQL.
7879
* <p>
7980
* Since 3.5.1, this attribute can omit.
81+
* <p>
8082
* If this attribute omit, the MyBatis will call a method that decide by following rules.
8183
* <ul>
8284
* <li>
@@ -92,6 +94,7 @@
9294
*
9395
* @return a method name of method for providing an SQL
9496
*/
97+
// @formatter:on
9598
String method() default "";
9699

97100
/**

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

+3
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,12 @@
7373
*/
7474
Class<?> type() default void.class;
7575

76+
// @formatter:off
7677
/**
7778
* Specify a method for providing an SQL.
7879
* <p>
7980
* Since 3.5.1, this attribute can omit.
81+
* <p>
8082
* If this attribute omit, the MyBatis will call a method that decide by following rules.
8183
* <ul>
8284
* <li>
@@ -92,6 +94,7 @@
9294
*
9395
* @return a method name of method for providing an SQL
9496
*/
97+
// @formatter:on
9598
String method() default "";
9699

97100
/**

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ public interface ProviderMethodResolver {
3939
* <p>
4040
* The default implementation return a method that matches following conditions.
4141
* <ul>
42-
* <li>Method name matches with mapper method</li>
43-
* <li>Return type matches the {@link CharSequence}({@link String}, {@link StringBuilder}, etc...)</li>
42+
* <li>Method name matches with mapper method</li>
43+
* <li>Return type matches the {@link CharSequence}({@link String}, {@link StringBuilder}, etc...)</li>
4444
* </ul>
4545
* If matched method is zero or multiple, it throws a {@link BuilderException}.
4646
*

src/main/java/org/apache/ibatis/jdbc/Null.java

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 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.
@@ -45,28 +45,45 @@ public enum Null {
4545
BOOLEAN(new BooleanTypeHandler(), JdbcType.BOOLEAN),
4646

4747
BYTE(new ByteTypeHandler(), JdbcType.TINYINT),
48+
4849
SHORT(new ShortTypeHandler(), JdbcType.SMALLINT),
50+
4951
INTEGER(new IntegerTypeHandler(), JdbcType.INTEGER),
52+
5053
LONG(new LongTypeHandler(), JdbcType.BIGINT),
54+
5155
FLOAT(new FloatTypeHandler(), JdbcType.FLOAT),
56+
5257
DOUBLE(new DoubleTypeHandler(), JdbcType.DOUBLE),
58+
5359
BIGDECIMAL(new BigDecimalTypeHandler(), JdbcType.DECIMAL),
5460

5561
STRING(new StringTypeHandler(), JdbcType.VARCHAR),
62+
5663
CLOB(new ClobTypeHandler(), JdbcType.CLOB),
64+
5765
LONGVARCHAR(new ClobTypeHandler(), JdbcType.LONGVARCHAR),
5866

5967
BYTEARRAY(new ByteArrayTypeHandler(), JdbcType.LONGVARBINARY),
68+
6069
BLOB(new BlobTypeHandler(), JdbcType.BLOB),
70+
6171
LONGVARBINARY(new BlobTypeHandler(), JdbcType.LONGVARBINARY),
6272

6373
OBJECT(new ObjectTypeHandler(), JdbcType.OTHER),
74+
6475
OTHER(new ObjectTypeHandler(), JdbcType.OTHER),
76+
6577
TIMESTAMP(new DateTypeHandler(), JdbcType.TIMESTAMP),
78+
6679
DATE(new DateOnlyTypeHandler(), JdbcType.DATE),
80+
6781
TIME(new TimeOnlyTypeHandler(), JdbcType.TIME),
82+
6883
SQLTIMESTAMP(new SqlTimestampTypeHandler(), JdbcType.TIMESTAMP),
84+
6985
SQLDATE(new SqlDateTypeHandler(), JdbcType.DATE),
86+
7087
SQLTIME(new SqlTimeTypeHandler(), JdbcType.TIME);
7188

7289
private final TypeHandler<?> typeHandler;

src/main/java/org/apache/ibatis/mapping/ResultSetType.java

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2009-2022 the original author or authors.
2+
* Copyright 2009-2023 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.
@@ -26,9 +26,7 @@ public enum ResultSetType {
2626
*
2727
* @since 3.5.0
2828
*/
29-
DEFAULT(-1),
30-
FORWARD_ONLY(ResultSet.TYPE_FORWARD_ONLY),
31-
SCROLL_INSENSITIVE(ResultSet.TYPE_SCROLL_INSENSITIVE),
29+
DEFAULT(-1), FORWARD_ONLY(ResultSet.TYPE_FORWARD_ONLY), SCROLL_INSENSITIVE(ResultSet.TYPE_SCROLL_INSENSITIVE),
3230
SCROLL_SENSITIVE(ResultSet.TYPE_SCROLL_SENSITIVE);
3331

3432
private final int value;

src/main/java/org/apache/ibatis/type/JdbcType.java

+41-2
Original file line numberDiff line numberDiff line change
@@ -24,49 +24,88 @@
2424
*/
2525
public enum JdbcType {
2626
/*
27-
* This is added to enable basic support for the
28-
* ARRAY data type - but a custom type handler is still required
27+
* This is added to enable basic support for the ARRAY data type - but a custom type handler is still required
2928
*/
3029
ARRAY(Types.ARRAY),
30+
3131
BIT(Types.BIT),
32+
3233
TINYINT(Types.TINYINT),
34+
3335
SMALLINT(Types.SMALLINT),
36+
3437
INTEGER(Types.INTEGER),
38+
3539
BIGINT(Types.BIGINT),
40+
3641
FLOAT(Types.FLOAT),
42+
3743
REAL(Types.REAL),
44+
3845
DOUBLE(Types.DOUBLE),
46+
3947
NUMERIC(Types.NUMERIC),
48+
4049
DECIMAL(Types.DECIMAL),
50+
4151
CHAR(Types.CHAR),
52+
4253
VARCHAR(Types.VARCHAR),
54+
4355
LONGVARCHAR(Types.LONGVARCHAR),
56+
4457
DATE(Types.DATE),
58+
4559
TIME(Types.TIME),
60+
4661
TIMESTAMP(Types.TIMESTAMP),
62+
4763
BINARY(Types.BINARY),
64+
4865
VARBINARY(Types.VARBINARY),
66+
4967
LONGVARBINARY(Types.LONGVARBINARY),
68+
5069
NULL(Types.NULL),
70+
5171
OTHER(Types.OTHER),
72+
5273
BLOB(Types.BLOB),
74+
5375
CLOB(Types.CLOB),
76+
5477
BOOLEAN(Types.BOOLEAN),
78+
5579
CURSOR(-10), // Oracle
80+
5681
UNDEFINED(Integer.MIN_VALUE + 1000),
82+
5783
NVARCHAR(Types.NVARCHAR), // JDK6
84+
5885
NCHAR(Types.NCHAR), // JDK6
86+
5987
NCLOB(Types.NCLOB), // JDK6
88+
6089
STRUCT(Types.STRUCT),
90+
6191
JAVA_OBJECT(Types.JAVA_OBJECT),
92+
6293
DISTINCT(Types.DISTINCT),
94+
6395
REF(Types.REF),
96+
6497
DATALINK(Types.DATALINK),
98+
6599
ROWID(Types.ROWID), // JDK6
100+
66101
LONGNVARCHAR(Types.LONGNVARCHAR), // JDK6
102+
67103
SQLXML(Types.SQLXML), // JDK6
104+
68105
DATETIMEOFFSET(-155), // SQL Server 2008
106+
69107
TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE), // JDBC 4.2 JDK8
108+
70109
TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE); // JDBC 4.2 JDK8
71110

72111
public final int TYPE_CODE;

src/test/java/org/apache/ibatis/builder/XmlConfigBuilderTest.java

+18-11
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,16 @@ void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
9696
assertThat(config.isSafeRowBoundsEnabled()).isFalse();
9797
assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.SESSION);
9898
assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.OTHER);
99-
assertThat(config.getLazyLoadTriggerMethods()).isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
99+
assertThat(config.getLazyLoadTriggerMethods())
100+
.isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
100101
assertThat(config.isSafeResultHandlerEnabled()).isTrue();
101102
assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(XMLLanguageDriver.class);
102103
assertThat(config.isCallSettersOnNulls()).isFalse();
103104
assertNull(config.getLogPrefix());
104105
assertNull(config.getLogImpl());
105106
assertNull(config.getConfigurationFactory());
106-
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumTypeHandler.class);
107+
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class))
108+
.isInstanceOf(EnumTypeHandler.class);
107109
assertThat(config.isShrinkWhitespacesInSql()).isFalse();
108110
assertThat(config.isArgNameBasedConstructorAutoMapping()).isFalse();
109111
assertThat(config.getDefaultSqlProviderType()).isNull();
@@ -195,7 +197,8 @@ void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
195197
assertThat(config.isSafeRowBoundsEnabled()).isTrue();
196198
assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.STATEMENT);
197199
assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.NULL);
198-
assertThat(config.getLazyLoadTriggerMethods()).isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx")));
200+
assertThat(config.getLazyLoadTriggerMethods())
201+
.isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx")));
199202
assertThat(config.isSafeResultHandlerEnabled()).isFalse();
200203
assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(RawLanguageDriver.class);
201204
assertThat(config.isCallSettersOnNulls()).isTrue();
@@ -212,11 +215,15 @@ void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
212215
assertThat(config.getTypeAliasRegistry().getTypeAliases().get("blog")).isEqualTo(Blog.class);
213216
assertThat(config.getTypeAliasRegistry().getTypeAliases().get("cart")).isEqualTo(Cart.class);
214217

215-
assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class)).isInstanceOf(CustomIntegerTypeHandler.class);
218+
assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class))
219+
.isInstanceOf(CustomIntegerTypeHandler.class);
216220
assertThat(config.getTypeHandlerRegistry().getTypeHandler(Long.class)).isInstanceOf(CustomLongTypeHandler.class);
217-
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class)).isInstanceOf(CustomStringTypeHandler.class);
218-
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR)).isInstanceOf(CustomStringTypeHandler.class);
219-
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumOrdinalTypeHandler.class);
221+
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class))
222+
.isInstanceOf(CustomStringTypeHandler.class);
223+
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR))
224+
.isInstanceOf(CustomStringTypeHandler.class);
225+
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class))
226+
.isInstanceOf(EnumOrdinalTypeHandler.class);
220227

221228
ExampleObjectFactory objectFactory = (ExampleObjectFactory) config.getObjectFactory();
222229
assertThat(objectFactory.getProperties().size()).isEqualTo(1);
@@ -265,7 +272,7 @@ void parseIsTwice() throws Exception {
265272

266273
when(builder::parse);
267274
then(caughtException()).isInstanceOf(BuilderException.class)
268-
.hasMessage("Each XMLConfigBuilder can only be used once.");
275+
.hasMessage("Each XMLConfigBuilder can only be used once.");
269276
}
270277
}
271278

@@ -282,7 +289,7 @@ void unknownSettings() {
282289
XMLConfigBuilder builder = new XMLConfigBuilder(new StringReader(MAPPER_CONFIG));
283290
when(builder::parse);
284291
then(caughtException()).isInstanceOf(BuilderException.class)
285-
.hasMessageContaining("The setting foo is not known. Make sure you spelled it correctly (case sensitive).");
292+
.hasMessageContaining("The setting foo is not known. Make sure you spelled it correctly (case sensitive).");
286293
}
287294

288295
@Test
@@ -337,8 +344,8 @@ void shouldAllowSubclassedConfiguration() throws IOException {
337344
void noDefaultConstructorForSubclassedConfiguration() throws IOException {
338345
String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
339346
try (InputStream inputStream = Resources.getResourceAsStream(resource)) {
340-
Exception exception = Assertions.assertThrows(Exception.class, () -> new XMLConfigBuilder(
341-
BadConfiguration.class, inputStream, null, null));
347+
Exception exception = Assertions.assertThrows(Exception.class,
348+
() -> new XMLConfigBuilder(BadConfiguration.class, inputStream, null, null));
342349
assertEquals("Failed to create a new Configuration instance.", exception.getMessage());
343350
}
344351
}

0 commit comments

Comments
 (0)