You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/09/21 15:12:42 UTC
[commons-dbcp] 03/06: Reuse Objects.equals().
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-dbcp.git
commit 72ff2333e07f9ece00c9088e496993367c1df13e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Sep 21 11:07:16 2020 -0400
Reuse Objects.equals().
---
.../java/org/apache/commons/dbcp2/PStmtKey.java | 43 ++++------------------
.../apache/commons/dbcp2/datasources/PoolKey.java | 13 ++-----
.../commons/dbcp2/datasources/UserPassKey.java | 7 +---
3 files changed, 13 insertions(+), 50 deletions(-)
diff --git a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
index 1bc4e23..f7769a4 100644
--- a/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/PStmtKey.java
@@ -20,6 +20,7 @@ import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Arrays;
+import java.util.Objects;
import org.apache.commons.dbcp2.PoolingConnection.StatementType;
@@ -798,18 +799,10 @@ public class PStmtKey {
return false;
}
final PStmtKey other = (PStmtKey) obj;
- if (autoGeneratedKeys == null) {
- if (other.autoGeneratedKeys != null) {
- return false;
- }
- } else if (!autoGeneratedKeys.equals(other.autoGeneratedKeys)) {
+ if (!Objects.equals(autoGeneratedKeys, other.autoGeneratedKeys)) {
return false;
}
- if (catalog == null) {
- if (other.catalog != null) {
- return false;
- }
- } else if (!catalog.equals(other.catalog)) {
+ if (!Objects.equals(catalog, other.catalog)) {
return false;
}
if (!Arrays.equals(columnIndexes, other.columnIndexes)) {
@@ -818,39 +811,19 @@ public class PStmtKey {
if (!Arrays.equals(columnNames, other.columnNames)) {
return false;
}
- if (resultSetConcurrency == null) {
- if (other.resultSetConcurrency != null) {
- return false;
- }
- } else if (!resultSetConcurrency.equals(other.resultSetConcurrency)) {
+ if (!Objects.equals(resultSetConcurrency, other.resultSetConcurrency)) {
return false;
}
- if (resultSetHoldability == null) {
- if (other.resultSetHoldability != null) {
- return false;
- }
- } else if (!resultSetHoldability.equals(other.resultSetHoldability)) {
+ if (!Objects.equals(resultSetHoldability, other.resultSetHoldability)) {
return false;
}
- if (resultSetType == null) {
- if (other.resultSetType != null) {
- return false;
- }
- } else if (!resultSetType.equals(other.resultSetType)) {
+ if (!Objects.equals(resultSetType, other.resultSetType)) {
return false;
}
- if (schema == null) {
- if (other.schema != null) {
- return false;
- }
- } else if (!schema.equals(other.schema)) {
+ if (!Objects.equals(schema, other.schema)) {
return false;
}
- if (sql == null) {
- if (other.sql != null) {
- return false;
- }
- } else if (!sql.equals(other.sql)) {
+ if (!Objects.equals(sql, other.sql)) {
return false;
}
if (statementType != other.statementType) {
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java b/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
index dfbdc4f..0aa70ea 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/PoolKey.java
@@ -18,6 +18,7 @@
package org.apache.commons.dbcp2.datasources;
import java.io.Serializable;
+import java.util.Objects;
/**
* @since 2.0
@@ -45,18 +46,10 @@ class PoolKey implements Serializable {
return false;
}
final PoolKey other = (PoolKey) obj;
- if (dataSourceName == null) {
- if (other.dataSourceName != null) {
- return false;
- }
- } else if (!dataSourceName.equals(other.dataSourceName)) {
+ if (!Objects.equals(dataSourceName, other.dataSourceName)) {
return false;
}
- if (userName == null) {
- if (other.userName != null) {
- return false;
- }
- } else if (!userName.equals(other.userName)) {
+ if (!Objects.equals(userName, other.userName)) {
return false;
}
return true;
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java b/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
index 094a6ba..789413c 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/UserPassKey.java
@@ -18,6 +18,7 @@
package org.apache.commons.dbcp2.datasources;
import java.io.Serializable;
+import java.util.Objects;
import org.apache.commons.dbcp2.Utils;
@@ -75,11 +76,7 @@ class UserPassKey implements Serializable {
return false;
}
final UserPassKey other = (UserPassKey) obj;
- if (userName == null) {
- if (other.userName != null) {
- return false;
- }
- } else if (!userName.equals(other.userName)) {
+ if (!Objects.equals(userName, other.userName)) {
return false;
}
return true;