Skip to content

[ci] formatting #2797

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.apache.ibatis.cache.decorators.LruCache;
import org.apache.ibatis.cache.impl.PerpetualCache;

// @formatter:off
/**
* The annotation that specify to use cache on namespace(e.g. mapper interface).
* <p>
Expand All @@ -44,6 +45,7 @@
* @author Clinton Begin
* @author Kazuki Shimizu
*/
// @formatter:on
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

// @formatter:off
/**
* The annotation that be grouping mapping definitions for constructor.
* <p>
Expand All @@ -40,6 +41,7 @@
*
* @author Clinton Begin
*/
// @formatter:on
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@
*/
Class<?> type() default void.class;

// @formatter:off
/**
* Specify a method for providing an SQL.
* <p>
* Since 3.5.1, this attribute can omit.
* <p>
* If this attribute omit, the MyBatis will call a method that decide by following rules.
* <ul>
* <li>
Expand All @@ -92,6 +94,7 @@
*
* @return a method name of method for providing an SQL
*/
// @formatter:on
String method() default "";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,12 @@
*/
Class<?> type() default void.class;

// @formatter:off
/**
* Specify a method for providing an SQL.
* <p>
* Since 3.5.1, this attribute can omit.
* <p>
* If this attribute omit, the MyBatis will call a method that decide by following rules.
* <ul>
* <li>
Expand All @@ -92,6 +94,7 @@
*
* @return a method name of method for providing an SQL
*/
// @formatter:on
String method() default "";

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public interface ProviderMethodResolver {
* <p>
* The default implementation return a method that matches following conditions.
* <ul>
* <li>Method name matches with mapper method</li>
* <li>Return type matches the {@link CharSequence}({@link String}, {@link StringBuilder}, etc...)</li>
* <li>Method name matches with mapper method</li>
* <li>Return type matches the {@link CharSequence}({@link String}, {@link StringBuilder}, etc...)</li>
* </ul>
* If matched method is zero or multiple, it throws a {@link BuilderException}.
*
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/org/apache/ibatis/jdbc/Null.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -45,28 +45,45 @@ public enum Null {
BOOLEAN(new BooleanTypeHandler(), JdbcType.BOOLEAN),

BYTE(new ByteTypeHandler(), JdbcType.TINYINT),

SHORT(new ShortTypeHandler(), JdbcType.SMALLINT),

INTEGER(new IntegerTypeHandler(), JdbcType.INTEGER),

LONG(new LongTypeHandler(), JdbcType.BIGINT),

FLOAT(new FloatTypeHandler(), JdbcType.FLOAT),

DOUBLE(new DoubleTypeHandler(), JdbcType.DOUBLE),

BIGDECIMAL(new BigDecimalTypeHandler(), JdbcType.DECIMAL),

STRING(new StringTypeHandler(), JdbcType.VARCHAR),

CLOB(new ClobTypeHandler(), JdbcType.CLOB),

LONGVARCHAR(new ClobTypeHandler(), JdbcType.LONGVARCHAR),

BYTEARRAY(new ByteArrayTypeHandler(), JdbcType.LONGVARBINARY),

BLOB(new BlobTypeHandler(), JdbcType.BLOB),

LONGVARBINARY(new BlobTypeHandler(), JdbcType.LONGVARBINARY),

OBJECT(new ObjectTypeHandler(), JdbcType.OTHER),

OTHER(new ObjectTypeHandler(), JdbcType.OTHER),

TIMESTAMP(new DateTypeHandler(), JdbcType.TIMESTAMP),

DATE(new DateOnlyTypeHandler(), JdbcType.DATE),

TIME(new TimeOnlyTypeHandler(), JdbcType.TIME),

SQLTIMESTAMP(new SqlTimestampTypeHandler(), JdbcType.TIMESTAMP),

SQLDATE(new SqlDateTypeHandler(), JdbcType.DATE),

SQLTIME(new SqlTimeTypeHandler(), JdbcType.TIME);

private final TypeHandler<?> typeHandler;
Expand Down
6 changes: 2 additions & 4 deletions src/main/java/org/apache/ibatis/mapping/ResultSetType.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2022 the original author or authors.
* Copyright 2009-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -26,9 +26,7 @@ public enum ResultSetType {
*
* @since 3.5.0
*/
DEFAULT(-1),
FORWARD_ONLY(ResultSet.TYPE_FORWARD_ONLY),
SCROLL_INSENSITIVE(ResultSet.TYPE_SCROLL_INSENSITIVE),
DEFAULT(-1), FORWARD_ONLY(ResultSet.TYPE_FORWARD_ONLY), SCROLL_INSENSITIVE(ResultSet.TYPE_SCROLL_INSENSITIVE),
SCROLL_SENSITIVE(ResultSet.TYPE_SCROLL_SENSITIVE);

private final int value;
Expand Down
43 changes: 41 additions & 2 deletions src/main/java/org/apache/ibatis/type/JdbcType.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,49 +24,88 @@
*/
public enum JdbcType {
/*
* This is added to enable basic support for the
* ARRAY data type - but a custom type handler is still required
* This is added to enable basic support for the ARRAY data type - but a custom type handler is still required
*/
ARRAY(Types.ARRAY),

BIT(Types.BIT),

TINYINT(Types.TINYINT),

SMALLINT(Types.SMALLINT),

INTEGER(Types.INTEGER),

BIGINT(Types.BIGINT),

FLOAT(Types.FLOAT),

REAL(Types.REAL),

DOUBLE(Types.DOUBLE),

NUMERIC(Types.NUMERIC),

DECIMAL(Types.DECIMAL),

CHAR(Types.CHAR),

VARCHAR(Types.VARCHAR),

LONGVARCHAR(Types.LONGVARCHAR),

DATE(Types.DATE),

TIME(Types.TIME),

TIMESTAMP(Types.TIMESTAMP),

BINARY(Types.BINARY),

VARBINARY(Types.VARBINARY),

LONGVARBINARY(Types.LONGVARBINARY),

NULL(Types.NULL),

OTHER(Types.OTHER),

BLOB(Types.BLOB),

CLOB(Types.CLOB),

BOOLEAN(Types.BOOLEAN),

CURSOR(-10), // Oracle

UNDEFINED(Integer.MIN_VALUE + 1000),

NVARCHAR(Types.NVARCHAR), // JDK6

NCHAR(Types.NCHAR), // JDK6

NCLOB(Types.NCLOB), // JDK6

STRUCT(Types.STRUCT),

JAVA_OBJECT(Types.JAVA_OBJECT),

DISTINCT(Types.DISTINCT),

REF(Types.REF),

DATALINK(Types.DATALINK),

ROWID(Types.ROWID), // JDK6

LONGNVARCHAR(Types.LONGNVARCHAR), // JDK6

SQLXML(Types.SQLXML), // JDK6

DATETIMEOFFSET(-155), // SQL Server 2008

TIME_WITH_TIMEZONE(Types.TIME_WITH_TIMEZONE), // JDBC 4.2 JDK8

TIMESTAMP_WITH_TIMEZONE(Types.TIMESTAMP_WITH_TIMEZONE); // JDBC 4.2 JDK8

public final int TYPE_CODE;
Expand Down
29 changes: 18 additions & 11 deletions src/test/java/org/apache/ibatis/builder/XmlConfigBuilderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,16 @@ void shouldSuccessfullyLoadMinimalXMLConfigFile() throws Exception {
assertThat(config.isSafeRowBoundsEnabled()).isFalse();
assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.SESSION);
assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.OTHER);
assertThat(config.getLazyLoadTriggerMethods()).isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
assertThat(config.getLazyLoadTriggerMethods())
.isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString")));
assertThat(config.isSafeResultHandlerEnabled()).isTrue();
assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(XMLLanguageDriver.class);
assertThat(config.isCallSettersOnNulls()).isFalse();
assertNull(config.getLogPrefix());
assertNull(config.getLogImpl());
assertNull(config.getConfigurationFactory());
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class))
.isInstanceOf(EnumTypeHandler.class);
assertThat(config.isShrinkWhitespacesInSql()).isFalse();
assertThat(config.isArgNameBasedConstructorAutoMapping()).isFalse();
assertThat(config.getDefaultSqlProviderType()).isNull();
Expand Down Expand Up @@ -195,7 +197,8 @@ void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
assertThat(config.isSafeRowBoundsEnabled()).isTrue();
assertThat(config.getLocalCacheScope()).isEqualTo(LocalCacheScope.STATEMENT);
assertThat(config.getJdbcTypeForNull()).isEqualTo(JdbcType.NULL);
assertThat(config.getLazyLoadTriggerMethods()).isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx")));
assertThat(config.getLazyLoadTriggerMethods())
.isEqualTo(new HashSet<>(Arrays.asList("equals", "clone", "hashCode", "toString", "xxx")));
assertThat(config.isSafeResultHandlerEnabled()).isFalse();
assertThat(config.getDefaultScriptingLanuageInstance()).isInstanceOf(RawLanguageDriver.class);
assertThat(config.isCallSettersOnNulls()).isTrue();
Expand All @@ -212,11 +215,15 @@ void shouldSuccessfullyLoadXMLConfigFile() throws Exception {
assertThat(config.getTypeAliasRegistry().getTypeAliases().get("blog")).isEqualTo(Blog.class);
assertThat(config.getTypeAliasRegistry().getTypeAliases().get("cart")).isEqualTo(Cart.class);

assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class)).isInstanceOf(CustomIntegerTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(Integer.class))
.isInstanceOf(CustomIntegerTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(Long.class)).isInstanceOf(CustomLongTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class)).isInstanceOf(CustomStringTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR)).isInstanceOf(CustomStringTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class)).isInstanceOf(EnumOrdinalTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class))
.isInstanceOf(CustomStringTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(String.class, JdbcType.VARCHAR))
.isInstanceOf(CustomStringTypeHandler.class);
assertThat(config.getTypeHandlerRegistry().getTypeHandler(RoundingMode.class))
.isInstanceOf(EnumOrdinalTypeHandler.class);

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

when(builder::parse);
then(caughtException()).isInstanceOf(BuilderException.class)
.hasMessage("Each XMLConfigBuilder can only be used once.");
.hasMessage("Each XMLConfigBuilder can only be used once.");
}
}

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

@Test
Expand Down Expand Up @@ -337,8 +344,8 @@ void shouldAllowSubclassedConfiguration() throws IOException {
void noDefaultConstructorForSubclassedConfiguration() throws IOException {
String resource = "org/apache/ibatis/builder/MinimalMapperConfig.xml";
try (InputStream inputStream = Resources.getResourceAsStream(resource)) {
Exception exception = Assertions.assertThrows(Exception.class, () -> new XMLConfigBuilder(
BadConfiguration.class, inputStream, null, null));
Exception exception = Assertions.assertThrows(Exception.class,
() -> new XMLConfigBuilder(BadConfiguration.class, inputStream, null, null));
assertEquals("Failed to create a new Configuration instance.", exception.getMessage());
}
}
Expand Down
Loading