Skip to content

Commit eaa6983

Browse files
authored
Merge pull request #2816 from hazendaz/copyright
[ci] Apply open rewrite partially on java cleanup
2 parents a99d783 + 630f017 commit eaa6983

File tree

35 files changed

+329
-286
lines changed

35 files changed

+329
-286
lines changed

src/main/java/org/apache/ibatis/cache/decorators/LoggingCache.java

Lines changed: 3 additions & 3 deletions
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,8 +26,8 @@ public class LoggingCache implements Cache {
2626

2727
private final Log log;
2828
private final Cache delegate;
29-
protected int requests = 0;
30-
protected int hits = 0;
29+
protected int requests;
30+
protected int hits;
3131

3232
public LoggingCache(Cache delegate) {
3333
this.delegate = delegate;

src/main/java/org/apache/ibatis/datasource/pooled/PoolState.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ public class PoolState {
2727

2828
protected final List<PooledConnection> idleConnections = new ArrayList<>();
2929
protected final List<PooledConnection> activeConnections = new ArrayList<>();
30-
protected long requestCount = 0;
31-
protected long accumulatedRequestTime = 0;
32-
protected long accumulatedCheckoutTime = 0;
33-
protected long claimedOverdueConnectionCount = 0;
34-
protected long accumulatedCheckoutTimeOfOverdueConnections = 0;
35-
protected long accumulatedWaitTime = 0;
36-
protected long hadToWaitCount = 0;
37-
protected long badConnectionCount = 0;
30+
protected long requestCount;
31+
protected long accumulatedRequestTime;
32+
protected long accumulatedCheckoutTime;
33+
protected long claimedOverdueConnectionCount;
34+
protected long accumulatedCheckoutTimeOfOverdueConnections;
35+
protected long accumulatedWaitTime;
36+
protected long hadToWaitCount;
37+
protected long badConnectionCount;
3838

3939
public PoolState(PooledDataSource dataSource) {
4040
this.dataSource = dataSource;

src/main/java/org/apache/ibatis/scripting/xmltags/DynamicContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public class DynamicContext {
4040

4141
private final ContextMap bindings;
4242
private final StringJoiner sqlBuilder = new StringJoiner(" ");
43-
private int uniqueNumber = 0;
43+
private int uniqueNumber;
4444

4545
public DynamicContext(Configuration configuration, Object parameterObject) {
4646
if (parameterObject != null && !(parameterObject instanceof Map)) {

src/main/java/org/apache/ibatis/session/Configuration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public class Configuration {
138138
protected ObjectFactory objectFactory = new DefaultObjectFactory();
139139
protected ObjectWrapperFactory objectWrapperFactory = new DefaultObjectWrapperFactory();
140140

141-
protected boolean lazyLoadingEnabled = false;
141+
protected boolean lazyLoadingEnabled;
142142
protected ProxyFactory proxyFactory = new JavassistProxyFactory(); // #224 Using internal Javassist instead of OGNL
143143

144144
protected String databaseId;

src/test/java/org/apache/ibatis/binding/BoundAuthorMapper.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public interface BoundAuthorMapper {
104104
" USERNAME as AUTHOR_USERNAME,",
105105
" PASSWORD as AUTHOR_PASSWORD,",
106106
" EMAIL as AUTHOR_EMAIL,",
107-
" BIO as AUTHOR_BIO," +
108-
" FAVOURITE_SECTION as AUTHOR_SECTION",
107+
" BIO as AUTHOR_BIO,"
108+
+ " FAVOURITE_SECTION as AUTHOR_SECTION",
109109
"FROM AUTHOR WHERE ID = #{id}"})
110110
// @formatter:on
111111
Author selectAuthorConstructor(int id);
@@ -125,8 +125,8 @@ public interface BoundAuthorMapper {
125125
" USERNAME as AUTHOR_USERNAME,",
126126
" PASSWORD as AUTHOR_PASSWORD,",
127127
" EMAIL as AUTHOR_EMAIL,",
128-
" BIO as AUTHOR_BIO," +
129-
" FAVOURITE_SECTION as AUTHOR_SECTION",
128+
" BIO as AUTHOR_BIO,"
129+
+ " FAVOURITE_SECTION as AUTHOR_SECTION",
130130
"FROM AUTHOR WHERE ID = #{id}"})
131131
// @formatter:on
132132
Author selectAuthorMapToConstructorUsingRepeatable(int id);
@@ -164,8 +164,8 @@ public interface BoundAuthorMapper {
164164
" USERNAME as AUTHOR_USERNAME,",
165165
" PASSWORD as AUTHOR_PASSWORD,",
166166
" EMAIL as AUTHOR_EMAIL,",
167-
" BIO as AUTHOR_BIO," +
168-
" FAVOURITE_SECTION as AUTHOR_SECTION",
167+
" BIO as AUTHOR_BIO,"
168+
+ " FAVOURITE_SECTION as AUTHOR_SECTION",
169169
"FROM AUTHOR WHERE ID = #{id}"})
170170
// @formatter:on
171171
Author selectAuthorUsingBothArgAndConstructorArgs(int id);

src/test/java/org/apache/ibatis/binding/BoundBlogMapper.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -128,16 +128,16 @@ public interface BoundBlogMapper {
128128
// ======================================================
129129

130130
// @formatter:off
131-
@Select("SELECT * FROM " +
132-
"blog WHERE id = #{id}")
131+
@Select("SELECT * FROM "
132+
+ "blog WHERE id = #{id}")
133133
// @formatter:on
134134
Blog selectBlog(int id);
135135

136136
// ======================================================
137137

138138
// @formatter:off
139-
@Select("SELECT * FROM " +
140-
"blog WHERE id = #{id}")
139+
@Select("SELECT * FROM "
140+
+ "blog WHERE id = #{id}")
141141
@ConstructorArgs({
142142
@Arg(column = "id", javaType = int.class, id = true),
143143
@Arg(column = "title", javaType = String.class),
@@ -158,47 +158,47 @@ public interface BoundBlogMapper {
158158
// ======================================================
159159

160160
// @formatter:off
161-
@Select("SELECT * FROM " +
162-
"blog WHERE id = #{id}")
161+
@Select("SELECT * FROM "
162+
+ "blog WHERE id = #{id}")
163163
// @formatter:on
164164
Map<String, Object> selectBlogAsMap(Map<String, Object> params);
165165

166166
// ======================================================
167167

168168
// @formatter:off
169-
@Select("SELECT * FROM " +
170-
"post WHERE subject like #{query}")
169+
@Select("SELECT * FROM "
170+
+ "post WHERE subject like #{query}")
171171
// @formatter:on
172172
List<Post> selectPostsLike(RowBounds bounds, String query);
173173

174174
// ======================================================
175175

176176
// @formatter:off
177-
@Select("SELECT * FROM " +
178-
"post WHERE subject like #{subjectQuery} and body like #{bodyQuery}")
177+
@Select("SELECT * FROM "
178+
+ "post WHERE subject like #{subjectQuery} and body like #{bodyQuery}")
179179
// @formatter:on
180180
List<Post> selectPostsLikeSubjectAndBody(RowBounds bounds, @Param("subjectQuery") String subjectQuery,
181181
@Param("bodyQuery") String bodyQuery);
182182

183183
// ======================================================
184184

185185
// @formatter:off
186-
@Select("SELECT * FROM " +
187-
"post WHERE id = #{id}")
186+
@Select("SELECT * FROM "
187+
+ "post WHERE id = #{id}")
188188
// @formatter:on
189189
List<Post> selectPostsById(int id);
190190

191191
// ======================================================
192192

193193
// @formatter:off
194-
@Select("SELECT * FROM blog " +
195-
"WHERE id = #{id} AND title = #{nonExistentParam,jdbcType=VARCHAR}")
194+
@Select("SELECT * FROM blog "
195+
+ "WHERE id = #{id} AND title = #{nonExistentParam,jdbcType=VARCHAR}")
196196
// @formatter:on
197197
Blog selectBlogByNonExistentParam(@Param("id") int id);
198198

199199
// @formatter:off
200-
@Select("SELECT * FROM blog " +
201-
"WHERE id = #{id} AND title = #{params.nonExistentParam,jdbcType=VARCHAR}")
200+
@Select("SELECT * FROM blog "
201+
+ "WHERE id = #{id} AND title = #{params.nonExistentParam,jdbcType=VARCHAR}")
202202
// @formatter:on
203203
Blog selectBlogByNonExistentNestedParam(@Param("id") int id, @Param("params") Map<String, Object> params);
204204

@@ -208,22 +208,22 @@ List<Post> selectPostsLikeSubjectAndBody(RowBounds bounds, @Param("subjectQuery"
208208
// ======================================================
209209

210210
// @formatter:off
211-
@Select("SELECT * FROM blog " +
212-
"WHERE id = #{0} AND title = #{1}")
211+
@Select("SELECT * FROM blog "
212+
+ "WHERE id = #{0} AND title = #{1}")
213213
// @formatter:on
214214
Blog selectBlogByDefault30ParamNames(int id, String title);
215215

216216
// @formatter:off
217-
@Select("SELECT * FROM blog " +
218-
"WHERE id = #{param1} AND title = #{param2}")
217+
@Select("SELECT * FROM blog "
218+
+ "WHERE id = #{param1} AND title = #{param2}")
219219
// @formatter:on
220220
Blog selectBlogByDefault31ParamNames(int id, String title);
221221

222222
// ======================================================
223223

224224
// @formatter:off
225-
@Select("SELECT * FROM blog " +
226-
"WHERE ${column} = #{id} AND title = #{value}")
225+
@Select("SELECT * FROM blog "
226+
+ "WHERE ${column} = #{id} AND title = #{value}")
227227
// @formatter:on
228228
Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id") int id,
229229
@Param("value") String title);
@@ -248,8 +248,8 @@ Blog selectBlogWithAParamNamedValue(@Param("column") String column, @Param("id")
248248
"FROM blog"
249249
})
250250
@Results({
251-
@Result(property = "author", column = "author_id", one = @One(select = "org.apache.ibatis.binding.BoundAuthorMapper.selectAuthor", fetchType=FetchType.EAGER)),
252-
@Result(property = "posts", column = "id", many = @Many(select = "selectPostsById", fetchType=FetchType.EAGER))
251+
@Result(property = "author", column = "author_id", one = @One(select = "org.apache.ibatis.binding.BoundAuthorMapper.selectAuthor", fetchType = FetchType.EAGER)),
252+
@Result(property = "posts", column = "id", many = @Many(select = "selectPostsById", fetchType = FetchType.EAGER))
253253
})
254254
// @formatter:on
255255
List<Blog> selectBlogsWithAutorAndPostsEagerly();

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

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ void mappedStatementWithoutOptionsWhenSpecifyDefaultValue() throws Exception {
8282
@Test
8383
void parseExpression() {
8484
BaseBuilder builder = new BaseBuilder(new Configuration()) {
85-
{
86-
}
8785
};
8886
{
8987
Pattern pattern = builder.parseExpression("[0-9]", "[a-z]");
@@ -100,8 +98,6 @@ void parseExpression() {
10098
@Test
10199
void resolveJdbcTypeWithUndefinedValue() {
102100
BaseBuilder builder = new BaseBuilder(new Configuration()) {
103-
{
104-
}
105101
};
106102
when(() -> builder.resolveJdbcType("aaa"));
107103
then(caughtException()).isInstanceOf(BuilderException.class)
@@ -112,8 +108,6 @@ void resolveJdbcTypeWithUndefinedValue() {
112108
@Test
113109
void resolveResultSetTypeWithUndefinedValue() {
114110
BaseBuilder builder = new BaseBuilder(new Configuration()) {
115-
{
116-
}
117111
};
118112
when(() -> builder.resolveResultSetType("bbb"));
119113
then(caughtException()).isInstanceOf(BuilderException.class)
@@ -124,8 +118,6 @@ void resolveResultSetTypeWithUndefinedValue() {
124118
@Test
125119
void resolveParameterModeWithUndefinedValue() {
126120
BaseBuilder builder = new BaseBuilder(new Configuration()) {
127-
{
128-
}
129121
};
130122
when(() -> builder.resolveParameterMode("ccc"));
131123
then(caughtException()).isInstanceOf(BuilderException.class)
@@ -136,8 +128,6 @@ void resolveParameterModeWithUndefinedValue() {
136128
@Test
137129
void createInstanceWithAbstractClass() {
138130
BaseBuilder builder = new BaseBuilder(new Configuration()) {
139-
{
140-
}
141131
};
142132
when(() -> builder.createInstance("org.apache.ibatis.builder.BaseBuilder"));
143133
then(caughtException()).isInstanceOf(BuilderException.class).hasMessage(
@@ -147,8 +137,6 @@ void createInstanceWithAbstractClass() {
147137
@Test
148138
void resolveClassWithNotFound() {
149139
BaseBuilder builder = new BaseBuilder(new Configuration()) {
150-
{
151-
}
152140
};
153141
when(() -> builder.resolveClass("ddd"));
154142
then(caughtException()).isInstanceOf(BuilderException.class).hasMessage(
@@ -158,8 +146,6 @@ void resolveClassWithNotFound() {
158146
@Test
159147
void resolveTypeHandlerTypeHandlerAliasIsNull() {
160148
BaseBuilder builder = new BaseBuilder(new Configuration()) {
161-
{
162-
}
163149
};
164150
TypeHandler<?> typeHandler = builder.resolveTypeHandler(String.class, (String) null);
165151
assertThat(typeHandler).isNull();
@@ -168,8 +154,6 @@ void resolveTypeHandlerTypeHandlerAliasIsNull() {
168154
@Test
169155
void resolveTypeHandlerNoAssignable() {
170156
BaseBuilder builder = new BaseBuilder(new Configuration()) {
171-
{
172-
}
173157
};
174158
when(() -> builder.resolveTypeHandler(String.class, "integer"));
175159
then(caughtException()).isInstanceOf(BuilderException.class).hasMessage(

src/test/java/org/apache/ibatis/cache/SerializedCacheTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@ public CachingObject(int x) {
6464

6565
@Override
6666
public boolean equals(Object o) {
67-
if (this == o)
67+
if (this == o) {
6868
return true;
69-
if (o == null || getClass() != o.getClass())
69+
}
70+
if (o == null || getClass() != o.getClass()) {
7071
return false;
72+
}
7173
CachingObject obj = (CachingObject) o;
7274
return x == obj.x;
7375
}
@@ -87,10 +89,12 @@ public CachingObjectWithoutSerializable(int x) {
8789

8890
@Override
8991
public boolean equals(Object o) {
90-
if (this == o)
92+
if (this == o) {
9193
return true;
92-
if (o == null || getClass() != o.getClass())
94+
}
95+
if (o == null || getClass() != o.getClass()) {
9396
return false;
97+
}
9498
CachingObjectWithoutSerializable obj = (CachingObjectWithoutSerializable) o;
9599
return x == obj.x;
96100
}

src/test/java/org/apache/ibatis/domain/blog/Author.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,25 +93,34 @@ public Section getFavouriteSection() {
9393

9494
@Override
9595
public boolean equals(Object o) {
96-
if (this == o)
96+
if (this == o) {
9797
return true;
98-
if (!(o instanceof Author))
98+
}
99+
if (!(o instanceof Author)) {
99100
return false;
101+
}
100102

101103
Author author = (Author) o;
102104

103-
if (id != author.id)
105+
if (id != author.id) {
104106
return false;
105-
if (bio != null ? !bio.equals(author.bio) : author.bio != null)
107+
}
108+
if (bio != null ? !bio.equals(author.bio) : author.bio != null) {
106109
return false;
107-
if (email != null ? !email.equals(author.email) : author.email != null)
110+
}
111+
if (email != null ? !email.equals(author.email) : author.email != null) {
108112
return false;
109-
if (password != null ? !password.equals(author.password) : author.password != null)
113+
}
114+
if (password != null ? !password.equals(author.password) : author.password != null) {
110115
return false;
111-
if (username != null ? !username.equals(author.username) : author.username != null)
116+
}
117+
if (username != null ? !username.equals(author.username) : author.username != null) {
112118
return false;
113-
if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) : author.favouriteSection != null)
119+
}
120+
if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection)
121+
: author.favouriteSection != null) {
114122
return false;
123+
}
115124

116125
return true;
117126
}

0 commit comments

Comments
 (0)