Skip to content

Commit

Permalink
Merge pull request #862 from jeffgbutler/remove-deprecations
Browse files Browse the repository at this point in the history
Cleanup Various Sonar Warnings
  • Loading branch information
jeffgbutler authored Oct 24, 2024
2 parents d819167 + d401491 commit c04c3b6
Show file tree
Hide file tree
Showing 22 changed files with 303 additions and 1,849 deletions.
3 changes: 1 addition & 2 deletions src/test/java/examples/array/StringArrayTypeHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.ibatis.type.BaseTypeHandler;
import org.apache.ibatis.type.JdbcType;
Expand Down Expand Up @@ -59,7 +58,7 @@ private String[] extractArray(Array array) throws SQLException {

List<String> stringList = Arrays.stream(objArray)
.map(Object::toString)
.collect(Collectors.toList());
.toList();

String[] stringArray = new String[stringList.size()];
return stringList.toArray(stringArray);
Expand Down
58 changes: 29 additions & 29 deletions src/test/java/examples/complexquery/GroupingTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,26 @@

class GroupingTest {
private static class Foo extends SqlTable {
public SqlColumn<Integer> A = column("A");
public SqlColumn<Integer> B = column("B");
public SqlColumn<Integer> C = column("C");
public SqlColumn<Integer> columnA = column("A");
public SqlColumn<Integer> columnB = column("B");
public SqlColumn<Integer> columnC = column("C");

public Foo() {
super("Foo");
}
}

private static final Foo foo = new Foo();
private static final SqlColumn<Integer> A = foo.A;
private static final SqlColumn<Integer> B = foo.B;
private static final SqlColumn<Integer> C = foo.C;
private static final SqlColumn<Integer> columnA = foo.columnA;
private static final SqlColumn<Integer> columnB = foo.columnB;
private static final SqlColumn<Integer> columnC = foo.columnC;

@Test
void testSimpleGrouping() {
SelectStatementProvider selectStatement = select(A, B, C)
SelectStatementProvider selectStatement = select(columnA, columnB, columnC)
.from(foo)
.where(A, isEqualTo(1), or(A, isEqualTo(2)))
.and(B, isEqualTo(3))
.where(columnA, isEqualTo(1), or(columnA, isEqualTo(2)))
.and(columnB, isEqualTo(3))
.build()
.render(RenderingStrategies.MYBATIS3);

Expand All @@ -68,14 +68,14 @@ void testSimpleGrouping() {

@Test
void testComplexGrouping() {
SelectStatementProvider selectStatement = select(A, B, C)
SelectStatementProvider selectStatement = select(columnA, columnB, columnC)
.from(foo)
.where(
group(A, isEqualTo(1), or(A, isGreaterThan(5))),
and(B, isEqualTo(1)),
or(A, isLessThan(0), and(B, isEqualTo(2)))
group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))),
and(columnB, isEqualTo(1)),
or(columnA, isLessThan(0), and(columnB, isEqualTo(2)))
)
.and(C, isEqualTo(1))
.and(columnC, isEqualTo(1))
.build()
.render(RenderingStrategies.MYBATIS3);

Expand All @@ -94,14 +94,14 @@ void testComplexGrouping() {

@Test
void testGroupAndExists() {
SelectStatementProvider selectStatement = select(A, B, C)
SelectStatementProvider selectStatement = select(columnA, columnB, columnC)
.from(foo)
.where(
group(exists(select(foo.allColumns()).from(foo).where(A, isEqualTo(3))), and (A, isEqualTo(1)), or(A, isGreaterThan(5))),
and(B, isEqualTo(1)),
or(A, isLessThan(0), and(B, isEqualTo(2)))
group(exists(select(foo.allColumns()).from(foo).where(columnA, isEqualTo(3))), and (columnA, isEqualTo(1)), or(columnA, isGreaterThan(5))),
and(columnB, isEqualTo(1)),
or(columnA, isLessThan(0), and(columnB, isEqualTo(2)))
)
.and(C, isEqualTo(1))
.and(columnC, isEqualTo(1))
.build()
.render(RenderingStrategies.MYBATIS3);

Expand All @@ -121,14 +121,14 @@ void testGroupAndExists() {

@Test
void testNestedGrouping() {
SelectStatementProvider selectStatement = select(A, B, C)
SelectStatementProvider selectStatement = select(columnA, columnB, columnC)
.from(foo)
.where(
group(group(A, isEqualTo(1), or(A, isGreaterThan(5))), and(A, isGreaterThan(5))),
and(group(A, isEqualTo(1), or(A, isGreaterThan(5))), or(B, isEqualTo(1))),
or(group(A, isEqualTo(1), or(A, isGreaterThan(5))), and(A, isLessThan(0), and(B, isEqualTo(2))))
group(group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))), and(columnA, isGreaterThan(5))),
and(group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))), or(columnB, isEqualTo(1))),
or(group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))), and(columnA, isLessThan(0), and(columnB, isEqualTo(2))))
)
.and(C, isEqualTo(1))
.and(columnC, isEqualTo(1))
.build()
.render(RenderingStrategies.MYBATIS3);

Expand All @@ -152,12 +152,12 @@ void testNestedGrouping() {

@Test
void testAndOrCriteriaGroups() {
SelectStatementProvider selectStatement = select(A, B, C)
SelectStatementProvider selectStatement = select(columnA, columnB, columnC)
.from(foo)
.where(A, isEqualTo(6))
.and(C, isEqualTo(1))
.and(group(A, isEqualTo(1), or(A, isGreaterThan(5))), or(B, isEqualTo(1)))
.or(group(A, isEqualTo(1), or(A, isGreaterThan(5))), and(A, isLessThan(0), and(B, isEqualTo(2))))
.where(columnA, isEqualTo(6))
.and(columnC, isEqualTo(1))
.and(group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))), or(columnB, isEqualTo(1)))
.or(group(columnA, isEqualTo(1), or(columnA, isGreaterThan(5))), and(columnA, isLessThan(0), and(columnB, isEqualTo(2))))
.build()
.render(RenderingStrategies.MYBATIS3);

Expand Down
4 changes: 2 additions & 2 deletions src/test/java/examples/emptywhere/EmptyWhereTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void testJoinThreeConditions() {
String lName = "Flintstone";

QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder = select(id, firstName, PersonDynamicSqlSupport.lastName, orderDate)
.from(person).join(order).on(person.id, equalTo(order.personId))
.from(person).join(order).on(person.id, isEqualTo(order.personId))
.where(id, isEqualTo(3));

builder.and(firstName, isEqualTo(fName).filter(Objects::nonNull));
Expand All @@ -192,7 +192,7 @@ void testJoinThreeConditions() {
@MethodSource("joinWhereVariations")
void testJoinVariations(Variation variation) {
QueryExpressionDSL<SelectModel>.QueryExpressionWhereBuilder builder = select(id, firstName, PersonDynamicSqlSupport.lastName, orderDate)
.from(person).join(order).on(person.id, equalTo(order.personId))
.from(person).join(order).on(person.id, isEqualTo(order.personId))
.where();

builder.and(firstName, isEqualTo(variation.firstName).filter(Objects::nonNull));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ default List<GeneratedAlwaysRecord> select(SelectDSLCompleter completer) {
return MyBatis3Utils.selectList(this::selectMany, selectList, generatedAlways, completer);
}

default Optional<GeneratedAlwaysRecord> selectByPrimaryKey(Integer _id) {
return selectOne(c -> c.where(id, isEqualTo(_id)));
default Optional<GeneratedAlwaysRecord> selectByPrimaryKey(Integer recordId) {
return selectOne(c -> c.where(id, isEqualTo(recordId)));
}

default int insert(GeneratedAlwaysRecord row) {
Expand Down
10 changes: 5 additions & 5 deletions src/test/java/examples/groupby/GroupByTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void testGroupByAfterJoin() {
CommonSelectMapper mapper = session.getMapper(CommonSelectMapper.class);

SelectStatementProvider selectStatement = select(lastName, streetAddress, count().as("count"))
.from(person, "p").join(address, "a").on(person.addressId, equalTo(address.id))
.from(person, "p").join(address, "a").on(person.addressId, isEqualTo(address.id))
.groupBy(lastName, streetAddress)
.build()
.render(RenderingStrategies.MYBATIS3);
Expand Down Expand Up @@ -156,10 +156,10 @@ void testUnionAfterJoin() {
CommonSelectMapper mapper = session.getMapper(CommonSelectMapper.class);

SelectStatementProvider selectStatement = select(lastName, firstName, streetAddress)
.from(person, "p").join(address, "a").on(person.addressId, equalTo(address.id))
.from(person, "p").join(address, "a").on(person.addressId, isEqualTo(address.id))
.union()
.select(person2.lastName, person2.firstName, streetAddress)
.from(person2, "p").join(address, "a").on(person2.addressId, equalTo(address.id))
.from(person2, "p").join(address, "a").on(person2.addressId, isEqualTo(address.id))
.orderBy(lastName, firstName)
.build()
.render(RenderingStrategies.MYBATIS3);
Expand Down Expand Up @@ -192,10 +192,10 @@ void testUnionAllAfterJoin() {
CommonSelectMapper mapper = session.getMapper(CommonSelectMapper.class);

SelectStatementProvider selectStatement = select(lastName, firstName, streetAddress)
.from(person, "p").join(address, "a").on(person.addressId, equalTo(address.id))
.from(person, "p").join(address, "a").on(person.addressId, isEqualTo(address.id))
.unionAll()
.select(person2.lastName, person2.firstName, streetAddress)
.from(person2, "p").join(address, "a").on(person2.addressId, equalTo(address.id))
.from(person2, "p").join(address, "a").on(person2.addressId, isEqualTo(address.id))
.orderBy(lastName, firstName)
.build()
.render(RenderingStrategies.MYBATIS3);
Expand Down
Loading

0 comments on commit c04c3b6

Please sign in to comment.