Skip to content

Add private constructors per open rewrite / fix two tests that were invalid #2817

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 3 commits into from
Feb 20, 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
2 changes: 1 addition & 1 deletion src/main/java/org/apache/ibatis/io/Resources.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class Resources {
*/
private static Charset charset;

Resources() {
private Resources() {
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/apache/ibatis/io/VFS.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ static VFS createVFS() {

return vfs;
}

private VFSHolder() {
}
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/apache/ibatis/reflection/ArrayUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,7 @@ public static String toString(Object obj) {
}
}

private ArrayUtil() {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ static class MySqlProvider {
public static String provideSql() {
return "SELECT 1";
}

private MySqlProvider() {
}
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,7 @@ public static void selectAuthorViaOutParams(int id, String[] username, String[]
bio[0] = rs.getString("bio");
}
}

private StoredProcedures() {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -682,4 +682,7 @@ static MappedStatement prepareInsertAuthorMappedStatementWithBeforeAutoKey(final
}).build()).cache(authorCache).keyGenerator(new SelectKeyGenerator(kms, true)).keyProperty("id").build();
}

private ExecutorTestHelper() {
}

}
4 changes: 0 additions & 4 deletions src/test/java/org/apache/ibatis/io/ResourcesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,4 @@ void shouldGetReaderWithClassLoader() throws IOException {

}

@Test
void stupidJustForCoverage() {
assertNotNull(new Resources());
}
}
4 changes: 2 additions & 2 deletions src/test/java/org/apache/ibatis/reflection/ArrayUtilTest.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 @@ -21,7 +21,7 @@

import org.junit.jupiter.api.Test;

class ArrayUtilTest extends ArrayUtil {
class ArrayUtilTest {

@Test
void testHashCode() {
Expand Down
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 @@ -48,5 +48,8 @@ static class MyProvider {
public static String getSql() {
return "insert into users (name) values (#{name}) returning id, name";
}

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

private CustomUtil() {
}
}
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 @@ -71,6 +71,9 @@ static SupportClasses.CustomCache unwrap(Cache cache) {
field.setAccessible(false);
}
}

private Utils() {
}
}

}
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 @@ -18,4 +18,7 @@
public class StaticClass {

public static String value = "User1";

private StaticClass() {
}
}
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 @@ -58,4 +58,7 @@ public static List<Product> selectAllProducts() {
}
}

private ProductDAO() {
}

}
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 @@ -28,6 +28,9 @@ class SqlProvider {
public static String getUser() {
return "SELECT * FROM users WHERE id = #{id}";
}

private SqlProvider() {
}
}

}
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 @@ -30,6 +30,9 @@ class SqlProvider {
public static String getUser() {
return "SELECT * FROM users WHERE id = #{id}";
}

private SqlProvider() {
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ public static String updateUserNameUsingProvider() {
public static String delete() {
return "DELETE FROM users WHERE name LIKE '%HSQL%'";
}

private HsqlSqlProvider() {
}
}

class DerbySqlProvider {
Expand All @@ -128,6 +131,9 @@ public static String updateUserNameUsingProvider() {
public static String delete() {
return "DELETE FROM users WHERE name LIKE '%DERBY%'";
}

private DerbySqlProvider() {
}
}

class DefaultSqlProvider {
Expand All @@ -146,6 +152,9 @@ public static String updateUserNameUsingProvider() {
public static String delete() {
return "DELETE FROM users WHERE name LIKE '%DEFAULT%'";
}

private DefaultSqlProvider() {
}
}

}
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 @@ -58,4 +58,7 @@ private static Object deserialzeObject(byte[] aSerializedObject) {
}
}

private UtilityTester() {
}

}
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 @@ -168,6 +168,9 @@ class ReservedMethodNameBasedSqlProvider {
public static String provideSql() {
return "DELETE FROM memos WHERE id = 1";
}

private ReservedMethodNameBasedSqlProvider() {
}
}

class CustomMethodResolverBasedSqlProvider implements CustomProviderMethodResolver {
Expand Down Expand Up @@ -247,6 +250,9 @@ class SqlProvider {
public static String select() {
return "SELECT 1 FROM INFORMATION_SCHEMA.SYSTEM_USERS";
}

private SqlProvider() {
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,9 @@ public static String provideSql(ProviderContext c) {
}
}

private SqlProvider() {
}

}

}
Expand Down Expand Up @@ -920,6 +923,9 @@ public static String multipleMap(@Param("map1") Map<String, Object> map1,
return "SELECT '" + map1.get("value") + map2.get("value") + "' FROM INFORMATION_SCHEMA.SYSTEM_USERS";
}

private SqlProvider() {
}

}

}
Expand Down Expand Up @@ -996,6 +1002,9 @@ public static String provideSql(ProviderContext context) {
return "SELECT '" + context.getDatabaseId() + "' FROM SYSIBM.SYSDUMMY1";
}
}

private SqlProvider() {
}
}
}

Expand Down