Skip to content

Commit

Permalink
Merge pull request #3362 from hazendaz/pom-cleanup
Browse files Browse the repository at this point in the history
tests: Use final and add constructor where needed
  • Loading branch information
hazendaz authored Dec 31, 2024
2 parents 5d995de + 2fb75f5 commit eee66f1
Show file tree
Hide file tree
Showing 21 changed files with 42 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ void propertiesSpecifyResourceAndUrlAtSameTime() {
"The properties element cannot specify both a URL and a resource based property file reference. Please specify one or the other.");
}

static class MySqlProvider {
static final class MySqlProvider {
@SuppressWarnings("unused")
public static String provideSql() {
return "SELECT 1";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -21,7 +21,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;

public class StoredProcedures {
public final class StoredProcedures {
public static void selectTwoSetsOfTwoAuthors(int p1, int p2, ResultSet[] rs1, ResultSet[] rs2) throws SQLException {
try (Connection conn = DriverManager.getConnection("jdbc:default:connection")) {
PreparedStatement ps1 = conn.prepareStatement("select * from author where id in (?,?)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.TypeHandlerRegistry;

class ExecutorTestHelper {
final class ExecutorTestHelper {

static final Cache authorCache;

Expand Down
5 changes: 4 additions & 1 deletion src/test/java/org/apache/ibatis/plugin/PluginTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ void shouldPluginSwitchSchema() {
}
}

static class SchemaHolder {
static final class SchemaHolder {
private static ThreadLocal<String> value = ThreadLocal.withInitial(() -> "PUBLIC");

public static void set(String tenantName) {
Expand All @@ -70,6 +70,9 @@ public static void set(String tenantName) {
public static String get() {
return value.get();
}

private SchemaHolder() {
}
}

@Intercepts(@Signature(type = StatementHandler.class, method = "prepare", args = { Connection.class, Integer.class }))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -15,7 +15,7 @@
*/
package org.apache.ibatis.submitted.constructor_automapping;

public class Author {
public final class Author {

private final Integer id;
private String name;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -44,7 +44,7 @@ public interface Mapper {
@Insert("insert into users (name) values (#{name}) returning id, name")
int insert(User user);

static class MyProvider {
static final class MyProvider {
public static String getSql() {
return "insert into users (name) values (#{name}) returning id, name";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package org.apache.ibatis.submitted.discriminator;

public class Contract {
private Integer id;
private Owner owner;
private final Integer id;
private final Owner owner;

public Contract(Integer id, Owner owner) {
this.id = id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -15,7 +15,7 @@
*/
package org.apache.ibatis.submitted.dynsql;

public class CustomUtil {
public final class CustomUtil {
public static String esc(final String s) {
return s.replace("'", "''");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public String getMessage() {
}
};

private int value;
private final int value;

Mood(int value) {
this.value = value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -54,7 +54,7 @@ public void setName(String name) {
}
}

static class Utils {
static final class Utils {
static SupportClasses.CustomCache unwrap(Cache cache) {
Field field;
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -15,7 +15,7 @@
*/
package org.apache.ibatis.submitted.ognlstatic;

public class StaticClass {
public final class StaticClass {

public static String value = "User1";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class IbatisConfig {
public final class IbatisConfig {

private static SqlSessionFactory sqlSessionFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -20,7 +20,7 @@

import org.apache.ibatis.session.SqlSession;

public class ProductDAO {
public final class ProductDAO {

public static List<Integer> selectProductCodes() {
try (SqlSession session = IbatisConfig.getSession()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -24,7 +24,7 @@ public interface BothSelectAndSelectProviderMapper {
@SelectProvider(type = SqlProvider.class, method = "getUser")
User getUser(Integer id);

class SqlProvider {
final class SqlProvider {
public static String getUser() {
return "SELECT * FROM users WHERE id = #{id}";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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,7 +26,7 @@ public interface BothSelectContainerAndSelectProviderContainerMapper {
@SelectProvider(type = SqlProvider.class, method = "getUser")
User getUser(Integer id);

class SqlProvider {
final class SqlProvider {
public static String getUser() {
return "SELECT * FROM users WHERE id = #{id}";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -94,7 +94,7 @@ public interface Mapper {
@Select("SELECT COUNT(*) FROM users WHERE name LIKE '%' || #{dataabse} || '%'")
int countByCurrentDatabase(String database);

class HsqlSqlProvider {
final class HsqlSqlProvider {
public static String getUserUsingProvider() {
return "SELECT id, name, 'HSQL' as databaseName FROM users WHERE id = #{id}";
}
Expand All @@ -115,7 +115,7 @@ private HsqlSqlProvider() {
}
}

class DerbySqlProvider {
final class DerbySqlProvider {
public static String getUserUsingProvider() {
return "SELECT id, name, 'DERBY' as databaseName FROM users WHERE id = #{id}";
}
Expand All @@ -136,7 +136,7 @@ private DerbySqlProvider() {
}
}

class DefaultSqlProvider {
final class DefaultSqlProvider {
public static String getUserUsingProvider() {
return "SELECT id, name, 'DEFAULT' as databaseName FROM users WHERE id = #{id}";
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -21,7 +21,7 @@
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

public class UtilityTester {
public final class UtilityTester {

public static void serializeAndDeserializeObject(Object myObject) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public static String provideSelect2Sql() {
}
}

class ReservedMethodNameBasedSqlProvider {
final class ReservedMethodNameBasedSqlProvider {
public static String provideSql() {
return "DELETE FROM memos WHERE id = 1";
}
Expand Down Expand Up @@ -246,7 +246,7 @@ interface ReservedNameMethodIsNoneMapper {
@UpdateProvider(type = SqlProvider.class)
int update();

class SqlProvider {
final class SqlProvider {
public static String select() {
return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ public interface DefaultSqlProviderMapper {
@DeleteProvider
void delete(int id);

class SqlProvider {
final class SqlProvider {

public static String provideSql(ProviderContext c) {
return switch (c.getMapperMethod().getName()) {
Expand Down Expand Up @@ -840,7 +840,7 @@ public interface StaticMethodSqlProviderMapper {
String multipleMap(@Param("map1") Map<String, Object> map1, @Param("map2") Map<String, Object> map2);

@SuppressWarnings("unused")
class SqlProvider {
final class SqlProvider {

public static String noArgument() {
return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
Expand Down Expand Up @@ -989,7 +989,7 @@ interface DatabaseIdMapper {
String selectDatabaseId();

@SuppressWarnings("unused")
class SqlProvider {
final class SqlProvider {
public static String provideSql(ProviderContext context) {
if ("hsql".equals(context.getDatabaseId())) {
return "SELECT '" + context.getDatabaseId() + "' FROM INFORMATION_SCHEMA.SYSTEM_USERS";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import org.testcontainers.junit.jupiter.Testcontainers;

@Testcontainers
public class MysqlContainer {
public final class MysqlContainer {

private static final String DB_NAME = "mybatis_test";
private static final String USERNAME = "u";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2023 the original author or authors.
* Copyright 2009-2024 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 @@ -20,7 +20,7 @@
import org.apache.ibatis.datasource.unpooled.UnpooledDataSource;
import org.testcontainers.containers.PostgreSQLContainer;

public class PgContainer {
public final class PgContainer {

private static final String DB_NAME = "mybatis_test";
private static final String USERNAME = "u";
Expand Down

0 comments on commit eee66f1

Please sign in to comment.