From 37616ba39cc590f23f05c395f5578b1e8f37e228 Mon Sep 17 00:00:00 2001 From: Jeremy Landis Date: Mon, 26 May 2025 13:08:50 -0400 Subject: [PATCH] Modernize 'new Boolean' to 'Boolean.valueOf' --- .../com/ibatis/common/beans/BaseProbe.java | 4 +- .../logging/PreparedStatementLogProxy.java | 6 +- .../jdbc/logging/StatementLogProxy.java | 6 +- .../extensions/TypeHandlerCallback.java | 10 ++-- .../engine/builder/xml/SqlMapParser.java | 6 +- .../engine/type/TypeHandlerFactory.java | 2 +- .../com/ibatis/sqlmap/NestedIterateTest.java | 58 +++++++++---------- .../HundredsTypeHandlerCallback.java | 10 ++-- .../extensions/PirateTypeHandlerCallback.java | 10 ++-- 9 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/ibatis/common/beans/BaseProbe.java b/src/main/java/com/ibatis/common/beans/BaseProbe.java index af056768..ccd3572f 100644 --- a/src/main/java/com/ibatis/common/beans/BaseProbe.java +++ b/src/main/java/com/ibatis/common/beans/BaseProbe.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -97,7 +97,7 @@ protected Object getIndexedProperty(Object object, String indexedName) { } else if (list instanceof char[]) { value = Character.valueOf(((char[]) list)[i]); } else if (list instanceof boolean[]) { - value = new Boolean(((boolean[]) list)[i]); + value = Boolean.valueOf(((boolean[]) list)[i]); } else if (list instanceof byte[]) { value = Byte.valueOf(((byte[]) list)[i]); } else if (list instanceof double[]) { diff --git a/src/main/java/com/ibatis/common/jdbc/logging/PreparedStatementLogProxy.java b/src/main/java/com/ibatis/common/jdbc/logging/PreparedStatementLogProxy.java index 690b9740..036e72e8 100644 --- a/src/main/java/com/ibatis/common/jdbc/logging/PreparedStatementLogProxy.java +++ b/src/main/java/com/ibatis/common/jdbc/logging/PreparedStatementLogProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -89,9 +89,9 @@ public Object invoke(Object proxy, Method method, Object[] params) throws Throwa } else if ("equals".equals(method.getName())) { Object ps = params[0]; if (ps instanceof Proxy) { - return new Boolean(proxy == ps); + return Boolean.valueOf(proxy == ps); } - return new Boolean(false); + return Boolean.valueOf(false); } else if ("hashCode".equals(method.getName())) { return Integer.valueOf(proxy.hashCode()); } else { diff --git a/src/main/java/com/ibatis/common/jdbc/logging/StatementLogProxy.java b/src/main/java/com/ibatis/common/jdbc/logging/StatementLogProxy.java index ed0f0e54..4427c8d4 100644 --- a/src/main/java/com/ibatis/common/jdbc/logging/StatementLogProxy.java +++ b/src/main/java/com/ibatis/common/jdbc/logging/StatementLogProxy.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -73,9 +73,9 @@ public Object invoke(Object proxy, Method method, Object[] params) throws Throwa } else if ("equals".equals(method.getName())) { Object ps = params[0]; if (ps instanceof Proxy) { - return new Boolean(proxy == ps); + return Boolean.valueOf(proxy == ps); } - return new Boolean(false); + return Boolean.valueOf(false); } else if ("hashCode".equals(method.getName())) { return Integer.valueOf(proxy.hashCode()); } else { diff --git a/src/main/java/com/ibatis/sqlmap/client/extensions/TypeHandlerCallback.java b/src/main/java/com/ibatis/sqlmap/client/extensions/TypeHandlerCallback.java index d68360f5..fc5a8afe 100644 --- a/src/main/java/com/ibatis/sqlmap/client/extensions/TypeHandlerCallback.java +++ b/src/main/java/com/ibatis/sqlmap/client/extensions/TypeHandlerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -39,9 +39,9 @@ * public Object getResult(ResultGetter getter) throws SQLException { * String s = getter.getString(); * if (YES.equalsIgnoreCase(s)) { - * return new Boolean(true); + * return Boolean.valueOf(true); * } else if (NO.equalsIgnoreCase(s)) { - * return new Boolean(false); + * return Boolean.valueOf(false); * } else { * throw new SQLException("Unexpected value " + s + " found where " + YES + " or " + NO + " was expected."); * } @@ -58,9 +58,9 @@ * * public Object valueOf(String s) { * if (YES.equalsIgnoreCase(s)) { - * return new Boolean(true); + * return Boolean.valueOf(true); * } else if (NO.equalsIgnoreCase(s)) { - * return new Boolean(false); + * return Boolean.valueOf(false); * } else { * throw new SQLException("Unexpected value " + s + " found where " + YES + " or " + NO + " was expected."); * } diff --git a/src/main/java/com/ibatis/sqlmap/engine/builder/xml/SqlMapParser.java b/src/main/java/com/ibatis/sqlmap/engine/builder/xml/SqlMapParser.java index f7c8a78b..ea1399a1 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/builder/xml/SqlMapParser.java +++ b/src/main/java/com/ibatis/sqlmap/engine/builder/xml/SqlMapParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the original author or authors. + * Copyright 2004-2025 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. @@ -155,10 +155,10 @@ public void process(Node node) throws Exception { String type = attributes.getProperty("type"); String readOnlyAttr = attributes.getProperty("readOnly"); Boolean readOnly = readOnlyAttr == null || readOnlyAttr.length() <= 0 ? null - : new Boolean("true".equals(readOnlyAttr)); + : Boolean.valueOf("true".equals(readOnlyAttr)); String serializeAttr = attributes.getProperty("serialize"); Boolean serialize = serializeAttr == null || serializeAttr.length() <= 0 ? null - : new Boolean("true".equals(serializeAttr)); + : Boolean.valueOf("true".equals(serializeAttr)); type = state.getConfig().getTypeHandlerFactory().resolveAlias(type); Class clazz = Resources.classForName(type); if (readOnly == null) { diff --git a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java index 6ae74a3f..93cd97a8 100644 --- a/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java +++ b/src/main/java/com/ibatis/sqlmap/engine/type/TypeHandlerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. diff --git a/src/test/java/com/ibatis/sqlmap/NestedIterateTest.java b/src/test/java/com/ibatis/sqlmap/NestedIterateTest.java index c3584b13..b5886fed 100644 --- a/src/test/java/com/ibatis/sqlmap/NestedIterateTest.java +++ b/src/test/java/com/ibatis/sqlmap/NestedIterateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2023 the original author or authors. + * Copyright 2004-2025 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. @@ -270,13 +270,13 @@ void test09() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -294,13 +294,13 @@ void test09a() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -490,13 +490,13 @@ void test16() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(false)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(false)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -523,13 +523,13 @@ void test17() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(false)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(false)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -556,13 +556,13 @@ void test18() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(false)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(false)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -585,13 +585,13 @@ void test19() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(false)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(false)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { @@ -614,13 +614,13 @@ void test20() { NestedIterateParameterObject po = new NestedIterateParameterObject(); NestedIterateParameterObject.AndCondition andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Jeff", new Boolean(false)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Jeff", Boolean.valueOf(false)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); andCondition = new NestedIterateParameterObject.AndCondition(); - andCondition.addCondition("first_name =", "Matt", new Boolean(true)); - andCondition.addCondition("last_name =", "Jones", new Boolean(true)); + andCondition.addCondition("first_name =", "Matt", Boolean.valueOf(true)); + andCondition.addCondition("last_name =", "Jones", Boolean.valueOf(true)); po.addOrCondition(andCondition); try { diff --git a/src/test/java/com/ibatis/sqlmap/extensions/HundredsTypeHandlerCallback.java b/src/test/java/com/ibatis/sqlmap/extensions/HundredsTypeHandlerCallback.java index 237b8d3e..4191e607 100644 --- a/src/test/java/com/ibatis/sqlmap/extensions/HundredsTypeHandlerCallback.java +++ b/src/test/java/com/ibatis/sqlmap/extensions/HundredsTypeHandlerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -28,9 +28,9 @@ public class HundredsTypeHandlerCallback implements TypeHandlerCallback { public Object getResult(ResultGetter getter) throws SQLException { int i = getter.getInt(); if (i == 100) { - return new Boolean(true); + return Boolean.valueOf(true); } else if (i == 200) { - return new Boolean(false); + return Boolean.valueOf(false); } else { throw new SQLException("Unexpected value " + i + " found where 100 or 200 was expected."); } @@ -49,9 +49,9 @@ public void setParameter(ParameterSetter setter, Object parameter) throws SQLExc @Override public Object valueOf(String s) { if ("100".equalsIgnoreCase(s)) { - return new Boolean(true); + return Boolean.valueOf(true); } else if ("200".equalsIgnoreCase(s)) { - return new Boolean(false); + return Boolean.valueOf(false); } else { throw new SqlMapException("Unexpected value " + s + " found where 100 or 200 was expected."); } diff --git a/src/test/java/com/ibatis/sqlmap/extensions/PirateTypeHandlerCallback.java b/src/test/java/com/ibatis/sqlmap/extensions/PirateTypeHandlerCallback.java index 39b90db3..ee81dd37 100644 --- a/src/test/java/com/ibatis/sqlmap/extensions/PirateTypeHandlerCallback.java +++ b/src/test/java/com/ibatis/sqlmap/extensions/PirateTypeHandlerCallback.java @@ -1,5 +1,5 @@ /* - * Copyright 2004-2022 the original author or authors. + * Copyright 2004-2025 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. @@ -28,9 +28,9 @@ public class PirateTypeHandlerCallback implements TypeHandlerCallback { public Object getResult(ResultGetter getter) throws SQLException { String s = getter.getString(); if ("Aye".equalsIgnoreCase(s)) { - return new Boolean(true); + return Boolean.valueOf(true); } else if ("Nay".equalsIgnoreCase(s)) { - return new Boolean(false); + return Boolean.valueOf(false); } else { throw new SQLException("Unexpected value " + s + " found where 'Aye' or 'Nay' was expected."); } @@ -49,9 +49,9 @@ public void setParameter(ParameterSetter setter, Object parameter) throws SQLExc @Override public Object valueOf(String s) { if ("Aye".equalsIgnoreCase(s)) { - return new Boolean(true); + return Boolean.valueOf(true); } else if ("Nay".equalsIgnoreCase(s)) { - return new Boolean(false); + return Boolean.valueOf(false); } else { throw new SqlMapException("Unexpected value " + s + " found where 'Aye' or 'Nay' was expected."); }