You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by pa...@apache.org on 2022/09/12 05:16:44 UTC

[shardingsphere] branch master updated: Reuse ShardingSpherePreconditions.checkNotNull (#20934)

This is an automated email from the ASF dual-hosted git repository.

panjuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 7c61774af1a Reuse ShardingSpherePreconditions.checkNotNull (#20934)
7c61774af1a is described below

commit 7c61774af1a62ec3a89cb6911d5194ff54e4bcc7
Author: Liang Zhang <zh...@apache.org>
AuthorDate: Mon Sep 12 13:16:34 2022 +0800

    Reuse ShardingSpherePreconditions.checkNotNull (#20934)
---
 .../zipkin/advice/JDBCExecutorCallbackAdvice.java  |  7 +--
 .../protocol/mysql/constant/MySQLCharacterSet.java |  9 ++--
 .../packet/command/MySQLCommandPacketType.java     |  5 +-
 .../command/MySQLCommandPacketTypeLoaderTest.java  |  2 +-
 .../command/MySQLMySQLCommandPacketTypeTest.java   |  2 +-
 .../CountDatabaseDiscoveryRuleQueryResultSet.java  |  5 +-
 .../DatabaseDiscoveryDistSQLStatementVisitor.java  |  5 +-
 .../query/CountEncryptRuleQueryResultSet.java      |  5 +-
 .../core/EncryptDistSQLStatementVisitor.java       |  5 +-
 ...ReplicaWeightReadQueryLoadBalanceAlgorithm.java |  5 +-
 ...sactionWeightReadQueryLoadBalanceAlgorithm.java |  5 +-
 .../WeightReadQueryLoadBalanceAlgorithm.java       |  5 +-
 .../CountReadwriteSplittingRuleQueryResultSet.java |  5 +-
 .../ReadwriteSplittingRuleQueryResultSet.java      | 22 +++------
 .../ReadwriteSplittingDistSQLStatementVisitor.java |  5 +-
 .../query/CountShadowRuleQueryResultSet.java       |  5 +-
 .../supporter/ShadowRuleStatementSupporter.java    | 56 ++++------------------
 .../parser/core/ShadowDistSQLStatementVisitor.java |  5 +-
 .../parser/ShadowRuleBeanDefinitionParser.java     |  5 +-
 .../generator/impl/ConstraintTokenGenerator.java   |  5 +-
 .../query/CheckMigrationQueryResultSet.java        |  9 ++--
 .../core/MigrationDistSQLStatementVisitor.java     |  5 +-
 .../core/ShardingDistSQLStatementVisitor.java      | 15 ++----
 .../infra/binder/segment/table/TablesContext.java  |  5 +-
 .../statement/dml/InsertStatementContext.java      |  9 ++--
 .../statement/dml/SelectStatementContext.java      |  7 ++-
 .../metadata/url/StandardJdbcUrlParser.java        |  5 +-
 .../schema/builder/SystemSchemaBuilderRule.java    |  5 +-
 .../YamlAlgorithmConfigurationSwapper.java         |  5 +-
 .../builder/SystemSchemaBuilderRuleTest.java       |  2 +-
 .../result/impl/stream/StreamMergedResult.java     |  5 +-
 .../exception/ShardingSpherePreconditions.java     | 15 +++++-
 .../exception/ShardingSpherePreconditionsTest.java | 11 +++++
 .../metadata/ShardingSphereDatabaseMetaData.java   | 12 ++---
 .../authority/checker/AuthorityChecker.java        |  5 +-
 .../ingest/position/IntegerPrimaryKeyPosition.java |  5 +-
 .../ingest/position/StringPrimaryKeyPosition.java  |  5 +-
 .../progress/JobItemIncrementalTasksProgress.java  |  7 +--
 .../core/api/impl/AbstractPipelineJobAPIImpl.java  |  4 +-
 ...DataMatchDataConsistencyCalculateAlgorithm.java |  3 +-
 .../data/pipeline/core/job/PipelineJobIdUtils.java |  5 +-
 .../scenario/migration/MigrationJobAPIImpl.java    |  9 ++--
 .../mysql/ingest/binlog/BinlogPosition.java        |  5 +-
 .../postgresql/ingest/wal/WalPosition.java         |  5 +-
 .../SingleTableDropSchemaMetadataValidator.java    |  9 ++--
 .../advanced/resultset/FederationResultSet.java    |  7 ++-
 .../impl/SubqueryExpressionConverter.java          |  5 +-
 .../core/TrafficDistSQLStatementVisitor.java       | 10 +---
 .../jta/datasource/swapper/DataSourceSwapper.java  |  5 +-
 .../DataSourceXAResourceRecoveryHelper.java        | 10 ++--
 .../handler/DatabaseRequiredBackendHandler.java    | 11 ++---
 ...mentalProcessConfigurationSegmentConverter.java | 17 ++-----
 .../rule/CountSingleTableRuleQueryResultSet.java   |  5 +-
 .../statement/impl/OracleStatementSQLVisitor.java  |  5 +-
 .../parser/sql/common/util/WhereExtractUtil.java   |  5 +-
 .../mysql/MySQLContainerConfigurationFactory.java  |  2 +-
 .../SQLRewriteEngineTestParametersBuilder.java     |  2 +-
 57 files changed, 141 insertions(+), 283 deletions(-)

diff --git a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdvice.java b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdvice.java
index 9ed8a2fdfc2..5ebcbe46d65 100644
--- a/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdvice.java
+++ b/shardingsphere-agent/shardingsphere-agent-plugins/shardingsphere-agent-plugin-tracing/shardingsphere-agent-tracing-zipkin/src/main/java/org/apache/shardingsphere/agent/plugin/tracing/zipkin/advice/JDBCExecutorCallbackAdvice.java
@@ -44,12 +44,7 @@ public final class JDBCExecutorCallbackAdvice implements InstanceMethodAroundAdv
     @SuppressWarnings("unchecked")
     public void beforeMethod(final AdviceTargetObject target, final Method method, final Object[] args, final MethodInvocationResult result) {
         Span root = (Span) ((Map<String, Object>) args[2]).get(ZipkinConstants.ROOT_SPAN);
-        Span span;
-        if (null == root) {
-            span = Tracing.currentTracer().nextSpan().name(OPERATION_NAME);
-        } else {
-            span = Tracing.currentTracer().newChild(root.context()).name(OPERATION_NAME);
-        }
+        Span span = null == root ? Tracing.currentTracer().nextSpan().name(OPERATION_NAME) : Tracing.currentTracer().newChild(root.context()).name(OPERATION_NAME);
         span.tag(ZipkinConstants.Tags.COMPONENT, ZipkinConstants.COMPONENT_NAME);
         span.tag(ZipkinConstants.Tags.DB_TYPE, ZipkinConstants.DB_TYPE_VALUE);
         JDBCExecutionUnit executionUnit = (JDBCExecutionUnit) args[0];
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLCharacterSet.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLCharacterSet.java
index ca246e334ac..e08ebe302aa 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLCharacterSet.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/constant/MySQLCharacterSet.java
@@ -19,6 +19,7 @@ package org.apache.shardingsphere.db.protocol.mysql.constant;
 
 import lombok.Getter;
 import org.apache.shardingsphere.dialect.mysql.exception.UnknownCollationException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
@@ -334,12 +335,8 @@ public enum MySQLCharacterSet {
      */
     public static MySQLCharacterSet findById(final int id) {
         MySQLCharacterSet result = CHARACTER_SET_MAP.get(id);
-        if (null == result) {
-            throw new UnknownCollationException(id);
-        }
-        if (null == result.getCharset()) {
-            throw new UnknownCollationException(id);
-        }
+        ShardingSpherePreconditions.checkNotNull(result, new UnknownCollationException(id));
+        ShardingSpherePreconditions.checkNotNull(result.getCharset(), new UnknownCollationException(id));
         return result;
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketType.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketType.java
index 6395e16ae12..dd6bd81b624 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketType.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/main/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketType.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.db.protocol.mysql.packet.command;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 import org.apache.shardingsphere.db.protocol.packet.CommandPacketType;
@@ -273,9 +274,7 @@ public enum MySQLCommandPacketType implements CommandPacketType {
      */
     public static MySQLCommandPacketType valueOf(final int value) {
         MySQLCommandPacketType result = MYSQL_COMMAND_PACKET_TYPE_CACHE.get(value);
-        if (null == result) {
-            throw new IllegalArgumentException(String.format("Cannot find '%s' in command packet type", value));
-        }
+        Preconditions.checkNotNull(result, "Cannot find '%s' in command packet type", value);
         return result;
     }
 }
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoaderTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoaderTest.java
index 80dcc53e72c..e899aa23bd6 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoaderTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLCommandPacketTypeLoaderTest.java
@@ -34,7 +34,7 @@ public final class MySQLCommandPacketTypeLoaderTest {
         assertThat(MySQLCommandPacketTypeLoader.getCommandPacketType(payload), is(MySQLCommandPacketType.COM_QUIT));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void assertGetCommandPacketTypeError() {
         MySQLPacketPayload payload = mock(MySQLPacketPayload.class);
         when(payload.readInt1()).thenReturn(0, 0x21);
diff --git a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLMySQLCommandPacketTypeTest.java b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLMySQLCommandPacketTypeTest.java
index 7b51e37acbc..2e0d4b790f5 100644
--- a/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLMySQLCommandPacketTypeTest.java
+++ b/shardingsphere-db-protocol/shardingsphere-db-protocol-mysql/src/test/java/org/apache/shardingsphere/db/protocol/mysql/packet/command/MySQLMySQLCommandPacketTypeTest.java
@@ -29,7 +29,7 @@ public final class MySQLMySQLCommandPacketTypeTest {
         assertThat(MySQLCommandPacketType.valueOf(MySQLCommandPacketType.COM_SLEEP.getValue()), is(MySQLCommandPacketType.COM_SLEEP));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void assertGetValueWithIllegalArgument() {
         MySQLCommandPacketType.valueOf(-1);
     }
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/CountDatabaseDiscoveryRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/CountDatabaseDiscove [...]
index 8f3e7ca66e1..ccb993e48a2 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/CountDatabaseDiscoveryRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-handler/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/handler/query/CountDatabaseDiscoveryRuleQueryResultSet.java
@@ -67,10 +67,9 @@ public final class CountDatabaseDiscoveryRuleQueryResultSet implements DatabaseD
     private LinkedList<Object> buildRow(final LinkedList<Object> value, final String databaseName, final int count) {
         if (null == value) {
             return new LinkedList<>(Arrays.asList(databaseName, count));
-        } else {
-            value.set(1, (Integer) value.get(1) + count);
-            return value;
         }
+        value.set(1, (Integer) value.get(1) + count);
+        return value;
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-parser/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-parser/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryDistSQLSt [...]
index 444938ea665..5022ea0ee16 100644
--- a/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-parser/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-db-discovery/shardingsphere-db-discovery-distsql/shardingsphere-db-discovery-distsql-parser/src/main/java/org/apache/shardingsphere/dbdiscovery/distsql/parser/core/DatabaseDiscoveryDistSQLStatementVisitor.java
@@ -164,10 +164,7 @@ public final class DatabaseDiscoveryDistSQLStatementVisitor extends DatabaseDisc
     }
     
     private String getIdentifierValue(final ParseTree context) {
-        if (null == context) {
-            return null;
-        }
-        return new IdentifierValue(context.getText()).getValue();
+        return null == context ? null : new IdentifierValue(context.getText()).getValue();
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/CountEncryptRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/CountEncryptRuleQueryResultSet.java
index 1ec924ac7f5..a9a825ad8d4 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/CountEncryptRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-handler/src/main/java/org/apache/shardingsphere/encrypt/distsql/handler/query/CountEncryptRuleQueryResultSet.java
@@ -67,10 +67,9 @@ public final class CountEncryptRuleQueryResultSet implements DatabaseDistSQLResu
     private LinkedList<Object> buildRow(final LinkedList<Object> value, final String databaseName, final int count) {
         if (null == value) {
             return new LinkedList<>(Arrays.asList(databaseName, count));
-        } else {
-            value.set(1, (Integer) value.get(1) + count);
-            return value;
         }
+        value.set(1, (Integer) value.get(1) + count);
+        return value;
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
index faafef34a56..a0bbb57709c 100644
--- a/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-encrypt/shardingsphere-encrypt-distsql/shardingsphere-encrypt-distsql-parser/src/main/java/org/apache/shardingsphere/encrypt/distsql/parser/core/EncryptDistSQLStatementVisitor.java
@@ -106,10 +106,7 @@ public final class EncryptDistSQLStatementVisitor extends EncryptDistSQLStatemen
     }
     
     private String getIdentifierValue(final ParseTree context) {
-        if (null == context) {
-            return null;
-        }
-        return new IdentifierValue(context.getText()).getValue();
+        return null == context ? null : new IdentifierValue(context.getText()).getValue();
     }
     
     private Properties getAlgorithmProperties(final AlgorithmDefinitionContext ctx) {
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
index ef6e393f6b8..a349870213e 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/FixedReplicaWeightReadQueryLoadBalanceAlgorithm.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
 import org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
@@ -105,9 +106,7 @@ public final class FixedReplicaWeightReadQueryLoadBalanceAlgorithm implements Re
     
     private double getWeightValue(final String readDataSourceName) {
         Object weightObject = props.get(readDataSourceName);
-        if (null == weightObject) {
-            throw new IllegalStateException("Read database access weight is not configured:" + readDataSourceName);
-        }
+        Preconditions.checkNotNull(weightObject, "Read database `%s` access weight is not configured", readDataSourceName);
         double result;
         try {
             result = Double.parseDouble(weightObject.toString());
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
index f89f9580674..8975b2e0fb2 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/TransactionWeightReadQueryLoadBalanceAlgorithm.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
 import org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
@@ -99,9 +100,7 @@ public final class TransactionWeightReadQueryLoadBalanceAlgorithm implements Rea
     
     private double getWeightValue(final String readDataSourceName) {
         Object weightObject = props.get(readDataSourceName);
-        if (null == weightObject) {
-            throw new IllegalStateException("Read database access weight is not configured:" + readDataSourceName);
-        }
+        Preconditions.checkNotNull(weightObject, "Read database `%s` access weight is not configured", readDataSourceName);
         double result;
         try {
             result = Double.parseDouble(weightObject.toString());
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithm.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithm.java
index dfb6321df79..089b0d044bd 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithm.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-core/src/main/java/org/apache/shardingsphere/readwritesplitting/algorithm/loadbalance/WeightReadQueryLoadBalanceAlgorithm.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.readwritesplitting.algorithm.loadbalance;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import org.apache.shardingsphere.infra.context.transaction.TransactionConnectionContext;
 import org.apache.shardingsphere.readwritesplitting.spi.ReadQueryLoadBalanceAlgorithm;
@@ -102,9 +103,7 @@ public final class WeightReadQueryLoadBalanceAlgorithm implements ReadQueryLoadB
     
     private double getWeightValue(final String readDataSourceName) {
         Object weightObject = props.get(readDataSourceName);
-        if (null == weightObject) {
-            throw new IllegalStateException("Read database access weight is not configured:" + readDataSourceName);
-        }
+        Preconditions.checkNotNull(weightObject, "Read database `%s` access weight is not configured", readDataSourceName);
         double result;
         try {
             result = Double.parseDouble(weightObject.toString());
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/CountReadwriteSplittingRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/read [...]
index da0ad31bb5b..c9c66fdafda 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/CountReadwriteSplittingRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/CountReadwriteSplittingRuleQueryResultSet.java
@@ -67,10 +67,9 @@ public final class CountReadwriteSplittingRuleQueryResultSet implements Database
     private LinkedList<Object> buildRow(final LinkedList<Object> value, final String databaseName, final int count) {
         if (null == value) {
             return new LinkedList<>(Arrays.asList(databaseName, count));
-        } else {
-            value.set(1, (Integer) value.get(1) + count);
-            return value;
         }
+        value.set(1, (Integer) value.get(1) + count);
+        return value;
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwrite [...]
index a7babca2b85..7979500ab2e 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-handler/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/handler/query/ReadwriteSplittingRuleQueryResultSet.java
@@ -93,31 +93,21 @@ public final class ReadwriteSplittingRuleQueryResultSet implements DatabaseDistS
     }
     
     private String getAutoAwareDataSourceName(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig) {
-        if (null == dataSourceRuleConfig.getDynamicStrategy()) {
-            return "";
-        }
-        return dataSourceRuleConfig.getDynamicStrategy().getAutoAwareDataSourceName();
+        return null == dataSourceRuleConfig.getDynamicStrategy() ? "" : dataSourceRuleConfig.getDynamicStrategy().getAutoAwareDataSourceName();
     }
     
     private String getWriteDataSourceQueryEnabled(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig) {
-        if (null == dataSourceRuleConfig.getDynamicStrategy()) {
-            return "";
-        }
-        return dataSourceRuleConfig.getDynamicStrategy().getWriteDataSourceQueryEnabled();
+        return null == dataSourceRuleConfig.getDynamicStrategy() ? "" : dataSourceRuleConfig.getDynamicStrategy().getWriteDataSourceQueryEnabled();
     }
     
     private String getWriteDataSourceName(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig, final Map<String, String> exportDataSources) {
-        if (null != exportDataSources) {
-            return exportDataSources.get(ExportableItemConstants.PRIMARY_DATA_SOURCE_NAME);
-        }
-        return dataSourceRuleConfig.getStaticStrategy().getWriteDataSourceName();
+        return null == exportDataSources ? dataSourceRuleConfig.getStaticStrategy().getWriteDataSourceName() : exportDataSources.get(ExportableItemConstants.PRIMARY_DATA_SOURCE_NAME);
     }
     
     private String getReadDataSourceNames(final ReadwriteSplittingDataSourceRuleConfiguration dataSourceRuleConfig, final Map<String, String> exportDataSources) {
-        if (null != exportDataSources) {
-            return exportDataSources.get(ExportableItemConstants.REPLICA_DATA_SOURCE_NAMES);
-        }
-        return Joiner.on(",").join(dataSourceRuleConfig.getStaticStrategy().getReadDataSourceNames());
+        return null == exportDataSources
+                ? Joiner.on(",").join(dataSourceRuleConfig.getStaticStrategy().getReadDataSourceNames())
+                : exportDataSources.get(ExportableItemConstants.REPLICA_DATA_SOURCE_NAMES);
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwrit [...]
index 1f80ee0f613..a599c5bb0eb 100644
--- a/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-readwrite-splitting/shardingsphere-readwrite-splitting-distsql/shardingsphere-readwrite-splitting-distsql-parser/src/main/java/org/apache/shardingsphere/readwritesplitting/distsql/parser/core/ReadwriteSplittingDistSQLStatementVisitor.java
@@ -133,10 +133,7 @@ public final class ReadwriteSplittingDistSQLStatementVisitor extends ReadwriteSp
     }
     
     private String getIdentifierValue(final ParseTree context) {
-        if (null == context) {
-            return null;
-        }
-        return new IdentifierValue(context.getText()).getValue();
+        return null == context ? null : new IdentifierValue(context.getText()).getValue();
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/CountShadowRuleQueryResultSet.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/CountShadowRuleQueryResultSet.java
index 85756526292..52e6aaaf127 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/CountShadowRuleQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/query/CountShadowRuleQueryResultSet.java
@@ -67,10 +67,9 @@ public final class CountShadowRuleQueryResultSet implements DatabaseDistSQLResul
     private LinkedList<Object> buildRow(final LinkedList<Object> value, final String databaseName, final int count) {
         if (null == value) {
             return new LinkedList<>(Arrays.asList(databaseName, count));
-        } else {
-            value.set(1, (Integer) value.get(1) + count);
-            return value;
         }
+        value.set(1, (Integer) value.get(1) + count);
+        return value;
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
index 0dde5c47b49..9e2badf9b9a 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-handler/src/main/java/org/apache/shardingsphere/shadow/distsql/handler/supporter/ShadowRuleStatementSupporter.java
@@ -42,10 +42,7 @@ public final class ShadowRuleStatementSupporter {
      * @return rule names
      */
     public static List<String> getRuleNames(final ShadowRuleConfiguration ruleConfig) {
-        if (null == ruleConfig) {
-            return Collections.emptyList();
-        }
-        return new ArrayList<>(ruleConfig.getDataSources().keySet());
+        return null == ruleConfig ? Collections.emptyList() : new ArrayList<>(ruleConfig.getDataSources().keySet());
     }
     
     /**
@@ -55,36 +52,7 @@ public final class ShadowRuleStatementSupporter {
      * @return rule names
      */
     public static List<String> getRuleNames(final Collection<ShadowRuleSegment> segments) {
-        if (segments.isEmpty()) {
-            return Collections.emptyList();
-        }
-        return segments.stream().map(ShadowRuleSegment::getRuleName).collect(Collectors.toList());
-    }
-    
-    /**
-     * Get table names from the shadow rule configuration.
-     *
-     * @param ruleConfig shadow rule configuration
-     * @return table names
-     */
-    public static List<String> getTableNames(final ShadowRuleConfiguration ruleConfig) {
-        if (null == ruleConfig) {
-            return Collections.emptyList();
-        }
-        return new ArrayList<>(ruleConfig.getTables().keySet());
-    }
-    
-    /**
-     * Get the table names from the rules.
-     *
-     * @param segments shadow rule segments
-     * @return table names
-     */
-    public static List<String> getTableNames(final Collection<ShadowRuleSegment> segments) {
-        if (segments.isEmpty()) {
-            return Collections.emptyList();
-        }
-        return segments.stream().flatMap(each -> each.getShadowTableRules().keySet().stream()).collect(Collectors.toList());
+        return segments.isEmpty() ? Collections.emptyList() : segments.stream().map(ShadowRuleSegment::getRuleName).collect(Collectors.toList());
     }
     
     /**
@@ -94,10 +62,9 @@ public final class ShadowRuleStatementSupporter {
      * @return resource names
      */
     public static List<String> getResourceNames(final Collection<ShadowRuleSegment> segments) {
-        if (segments.isEmpty()) {
-            return Collections.emptyList();
-        }
-        return segments.stream().map(each -> Arrays.asList(each.getSource(), each.getShadow())).flatMap(Collection::stream).filter(Objects::nonNull).collect(Collectors.toList());
+        return segments.isEmpty()
+                ? Collections.emptyList()
+                : segments.stream().map(each -> Arrays.asList(each.getSource(), each.getShadow())).flatMap(Collection::stream).filter(Objects::nonNull).collect(Collectors.toList());
     }
     
     /**
@@ -107,10 +74,7 @@ public final class ShadowRuleStatementSupporter {
      * @return algorithm names
      */
     public static List<String> getAlgorithmNames(final ShadowRuleConfiguration ruleConfig) {
-        if (null == ruleConfig) {
-            return Collections.emptyList();
-        }
-        return new ArrayList<>(ruleConfig.getShadowAlgorithms().keySet());
+        return null == ruleConfig ? Collections.emptyList() : new ArrayList<>(ruleConfig.getShadowAlgorithms().keySet());
     }
     
     /**
@@ -120,10 +84,10 @@ public final class ShadowRuleStatementSupporter {
      * @return algorithm names
      */
     public static List<String> getAlgorithmNames(final Collection<ShadowRuleSegment> segments) {
-        if (segments.isEmpty()) {
-            return Collections.emptyList();
-        }
-        return segments.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream).map(ShadowAlgorithmSegment::getAlgorithmName).collect(Collectors.toList());
+        return segments.isEmpty()
+                ? Collections.emptyList()
+                : segments.stream().flatMap(each -> each.getShadowTableRules().values().stream()).flatMap(Collection::stream)
+                        .map(ShadowAlgorithmSegment::getAlgorithmName).collect(Collectors.toList());
     }
     
     /**
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java
index 6420f947fb2..2a657ca4f27 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-distsql/shardingsphere-shadow-distsql-parser/src/main/java/org/apache/shardingsphere/shadow/distsql/parser/core/ShadowDistSQLStatementVisitor.java
@@ -152,10 +152,7 @@ public final class ShadowDistSQLStatementVisitor extends ShadowDistSQLStatementB
     }
     
     private String getIdentifierValue(final ParserRuleContext ctx) {
-        if (null == ctx || ctx.isEmpty()) {
-            return null;
-        }
-        return new IdentifierValue(ctx.getText()).getValue();
+        return null == ctx || ctx.isEmpty() ? null : new IdentifierValue(ctx.getText()).getValue();
     }
     
     private Collection<ShadowAlgorithmSegment> visitShadowAlgorithms(final List<ShadowAlgorithmDefinitionContext> ctxs) {
diff --git a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
index ecdc011bda3..4522525a67c 100644
--- a/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
+++ b/shardingsphere-features/shardingsphere-shadow/shardingsphere-shadow-spring/shardingsphere-shadow-spring-namespace/src/main/java/org/apache/shardingsphere/shadow/spring/namespace/parser/ShadowRuleBeanDefinitionParser.java
@@ -71,10 +71,7 @@ public final class ShadowRuleBeanDefinitionParser extends AbstractBeanDefinition
     
     private String parseDefaultShadowAlgorithmName(final Element element) {
         Element defaultShadowAlgorithmElement = DomUtils.getChildElementByTagName(element, ShadowRuleBeanDefinitionTag.SHADOW_DEFAULT_SHADOW_ALGORITHM_NAME);
-        if (null == defaultShadowAlgorithmElement) {
-            return null;
-        }
-        return defaultShadowAlgorithmElement.getAttribute(ShadowRuleBeanDefinitionTag.SHADOW_NAME_ATTRIBUTE);
+        return null == defaultShadowAlgorithmElement ? null : defaultShadowAlgorithmElement.getAttribute(ShadowRuleBeanDefinitionTag.SHADOW_NAME_ATTRIBUTE);
     }
     
     private BeanDefinition parseShadowTableConfiguration(final Element element) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ConstraintTokenGenerator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ConstraintTokenGenerator.java
index 4e6136e8e32..c0394e7b1b8 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ConstraintTokenGenerator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-core/src/main/java/org/apache/shardingsphere/sharding/rewrite/token/generator/impl/ConstraintTokenGenerator.java
@@ -49,10 +49,9 @@ public final class ConstraintTokenGenerator implements CollectionSQLTokenGenerat
         if (sqlStatementContext instanceof ConstraintAvailable) {
             for (ConstraintSegment each : ((ConstraintAvailable) sqlStatementContext).getConstraints()) {
                 IdentifierValue constraintIdentifier = each.getIdentifier();
-                if (null == constraintIdentifier) {
-                    continue;
+                if (null != constraintIdentifier) {
+                    result.add(new ConstraintToken(each.getStartIndex(), each.getStopIndex(), constraintIdentifier, sqlStatementContext, shardingRule));
                 }
-                result.add(new ConstraintToken(each.getStartIndex(), each.getStopIndex(), constraintIdentifier, sqlStatementContext, shardingRule));
             }
         }
         return result;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/CheckMigrationQueryResultSet.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/CheckMigrationQueryResultSet.java
index 9b08eae1ead..e448711660d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/CheckMigrationQueryResultSet.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-handler/src/main/java/org/apache/shardingsphere/migration/distsql/handler/query/CheckMigrationQueryResultSet.java
@@ -45,13 +45,10 @@ public final class CheckMigrationQueryResultSet implements DatabaseDistSQLResult
     @Override
     public void init(final ShardingSphereDatabase database, final SQLStatement sqlStatement) {
         CheckMigrationStatement checkMigrationStatement = (CheckMigrationStatement) sqlStatement;
-        Map<String, DataConsistencyCheckResult> checkResultMap;
         AlgorithmSegment typeStrategy = checkMigrationStatement.getTypeStrategy();
-        if (null == typeStrategy) {
-            checkResultMap = JOB_API.dataConsistencyCheck(checkMigrationStatement.getJobId());
-        } else {
-            checkResultMap = JOB_API.dataConsistencyCheck(checkMigrationStatement.getJobId(), typeStrategy.getName(), typeStrategy.getProps());
-        }
+        Map<String, DataConsistencyCheckResult> checkResultMap = null == typeStrategy
+                ? JOB_API.dataConsistencyCheck(checkMigrationStatement.getJobId())
+                : JOB_API.dataConsistencyCheck(checkMigrationStatement.getJobId(), typeStrategy.getName(), typeStrategy.getProps());
         data = checkResultMap.entrySet().stream()
                 .map(each -> {
                     Collection<Object> result = new LinkedList<>();
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java
index f5fe3629aae..ba5be0ce157 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/migration/distsql/parser/core/MigrationDistSQLStatementVisitor.java
@@ -138,10 +138,7 @@ public final class MigrationDistSQLStatementVisitor extends MigrationDistSQLStat
     }
     
     private String getIdentifierValue(final ParseTree context) {
-        if (null == context) {
-            return null;
-        }
-        return new IdentifierValue(context.getText()).getValue();
+        return null == context ? null : new IdentifierValue(context.getText()).getValue();
     }
     
     @Override
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
index a5671a94d4d..d15a11255dc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-distsql/shardingsphere-sharding-distsql-parser/src/main/java/org/apache/shardingsphere/sharding/distsql/parser/core/ShardingDistSQLStatementVisitor.java
@@ -341,18 +341,12 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
     
     @Override
     public ASTNode visitKeyGenerateStrategy(final KeyGenerateStrategyContext ctx) {
-        if (null == ctx) {
-            return null;
-        }
-        return new KeyGenerateStrategySegment(getIdentifierValue(ctx.columnName()), getIdentifierValue(ctx.keyGenerator().shardingAlgorithmName()));
+        return null == ctx ? null : new KeyGenerateStrategySegment(getIdentifierValue(ctx.columnName()), getIdentifierValue(ctx.keyGenerator().shardingAlgorithmName()));
     }
     
     @Override
     public ASTNode visitKeyGenerateDefinition(final KeyGenerateDefinitionContext ctx) {
-        if (null == ctx) {
-            return null;
-        }
-        return new KeyGenerateStrategySegment(getIdentifierValue(ctx.columnName()), (AlgorithmSegment) visit(ctx.algorithmDefinition()));
+        return null == ctx ? null : new KeyGenerateStrategySegment(getIdentifierValue(ctx.columnName()), (AlgorithmSegment) visit(ctx.algorithmDefinition()));
     }
     
     @Override
@@ -385,10 +379,7 @@ public final class ShardingDistSQLStatementVisitor extends ShardingDistSQLStatem
     }
     
     private String getIdentifierValue(final ParseTree context) {
-        if (null == context) {
-            return null;
-        }
-        return new IdentifierValue(context.getText()).getValue();
+        return null == context ? null : new IdentifierValue(context.getText()).getValue();
     }
     
     private String getIdentifierValueForDataNodes(final ParseTree context) {
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContext.java
index cb9e0a81f9b..a759e4f3e7d 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/segment/table/TablesContext.java
@@ -226,10 +226,9 @@ public final class TablesContext {
     private Map<String, Collection<String>> getOwnerColumnNamesByColumnProjection(final Collection<ColumnProjection> columns) {
         Map<String, Collection<String>> result = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
         for (ColumnProjection each : columns) {
-            if (null == each.getOwner()) {
-                continue;
+            if (null != each.getOwner()) {
+                result.computeIfAbsent(each.getOwner(), unused -> new LinkedList<>()).add(each.getExpression());
             }
-            result.computeIfAbsent(each.getOwner(), unused -> new LinkedList<>()).add(each.getExpression());
         }
         return result;
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
index b47259f041a..15846351741 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/InsertStatementContext.java
@@ -32,6 +32,7 @@ import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSel
 import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import org.apache.shardingsphere.sql.parser.sql.common.extractor.TableExtractor;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.AssignmentSegment;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.dml.assignment.InsertValuesSegment;
@@ -98,13 +99,9 @@ public final class InsertStatementContext extends CommonSQLStatementContext<Inse
     
     private ShardingSphereSchema getSchema(final Map<String, ShardingSphereDatabase> databases, final String defaultDatabaseName) {
         String databaseName = tablesContext.getDatabaseName().orElse(defaultDatabaseName);
-        if (null == databaseName) {
-            throw new NoDatabaseSelectedException();
-        }
+        ShardingSpherePreconditions.checkNotNull(databaseName, new NoDatabaseSelectedException());
         ShardingSphereDatabase database = databases.get(databaseName.toLowerCase());
-        if (null == database) {
-            throw new UnknownDatabaseException(databaseName);
-        }
+        ShardingSpherePreconditions.checkNotNull(database, new UnknownDatabaseException(databaseName));
         String defaultSchema = DatabaseTypeEngine.getDefaultSchemaName(getDatabaseType(), databaseName);
         return tablesContext.getSchemaName().map(database::getSchema).orElseGet(() -> database.getSchema(defaultSchema));
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
index cc3755858ed..4e35e08153d 100644
--- a/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
+++ b/shardingsphere-infra/shardingsphere-infra-binder/src/main/java/org/apache/shardingsphere/infra/binder/statement/dml/SelectStatementContext.java
@@ -43,6 +43,7 @@ import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSel
 import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import org.apache.shardingsphere.sql.parser.sql.common.constant.ParameterMarkerType;
 import org.apache.shardingsphere.sql.parser.sql.common.constant.SubqueryType;
 import org.apache.shardingsphere.sql.parser.sql.common.extractor.TableExtractor;
@@ -136,9 +137,7 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
             throw new NoDatabaseSelectedException();
         }
         ShardingSphereDatabase database = databases.get(databaseName.toLowerCase());
-        if (null == database) {
-            throw new UnknownDatabaseException(databaseName);
-        }
+        ShardingSpherePreconditions.checkNotNull(database, new UnknownDatabaseException(databaseName));
         return database.getSchemas();
     }
     
@@ -162,7 +161,7 @@ public final class SelectStatementContext extends CommonSQLStatementContext<Sele
     
     /**
      * Judge whether contains having or not.
-     * 
+     *
      * @return whether contains having or not
      */
     public boolean isContainsHaving() {
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/url/StandardJdbcUrlParser.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/url/StandardJdbcUrlParser.java
index 7ef9327037c..12aa83eb614 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/url/StandardJdbcUrlParser.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/database/metadata/url/StandardJdbcUrlParser.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.infra.database.metadata.url;
 import com.google.common.base.Splitter;
 import com.google.common.base.Strings;
 import org.apache.shardingsphere.infra.database.metadata.UnrecognizedDatabaseURLException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 
 import java.util.Properties;
 import java.util.regex.Matcher;
@@ -56,9 +57,7 @@ public final class StandardJdbcUrlParser {
         Matcher matcher = CONNECTION_URL_PATTERN.matcher(jdbcUrl);
         if (matcher.matches()) {
             String authority = matcher.group(AUTHORITY_GROUP_KEY);
-            if (null == authority) {
-                throw new UnrecognizedDatabaseURLException(jdbcUrl, CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%"));
-            }
+            ShardingSpherePreconditions.checkNotNull(authority, new UnrecognizedDatabaseURLException(jdbcUrl, CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%")));
             return new JdbcUrl(parseHostname(authority), parsePort(authority), matcher.group(PATH_GROUP_KEY), parseQueryProperties(matcher.group(QUERY_GROUP_KEY)));
         }
         throw new UnrecognizedDatabaseURLException(jdbcUrl, CONNECTION_URL_PATTERN.pattern().replaceAll("%", "%%"));
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
index a1f6173d84b..bbdea445865 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRule.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.infra.metadata.database.schema.builder;
 
+import com.google.common.base.Preconditions;
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
 
@@ -101,9 +102,7 @@ public enum SystemSchemaBuilderRule {
     public static SystemSchemaBuilderRule valueOf(final String databaseType, final String schema) {
         String schemaPath = databaseType + "." + schema;
         SystemSchemaBuilderRule result = SCHEMA_PATH_SYSTEM_SCHEMA_BUILDER_RULE_MAP.get(schemaPath);
-        if (null == result) {
-            throw new IllegalArgumentException(String.format("Can not find builder rule: `%s`", schemaPath));
-        }
+        Preconditions.checkNotNull(result, "Can not find builder rule: `%s`", schemaPath);
         return result;
     }
     
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/algorithm/YamlAlgorithmConfigurationSwapper.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/algorithm/YamlAlgorithmConfigurationSwapper.java
index c3e012da854..362e4f2058c 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/algorithm/YamlAlgorithmConfigurationSwapper.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/yaml/config/swapper/algorithm/YamlAlgorithmConfigurationSwapper.java
@@ -39,9 +39,6 @@ public final class YamlAlgorithmConfigurationSwapper implements YamlConfiguratio
     
     @Override
     public AlgorithmConfiguration swapToObject(final YamlAlgorithmConfiguration yamlConfig) {
-        if (null == yamlConfig) {
-            return null;
-        }
-        return new AlgorithmConfiguration(yamlConfig.getType(), yamlConfig.getProps());
+        return null == yamlConfig ? null : new AlgorithmConfiguration(yamlConfig.getType(), yamlConfig.getProps());
     }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
index 1081cdf8b5b..23d09d2f321 100644
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/metadata/database/schema/builder/SystemSchemaBuilderRuleTest.java
@@ -37,7 +37,7 @@ public final class SystemSchemaBuilderRuleTest {
         assertThat(actual.getTables(), is(new HashSet<>(Arrays.asList("columns", "engines", "parameters", "routines", "schemata", "tables", "views"))));
     }
     
-    @Test(expected = IllegalArgumentException.class)
+    @Test(expected = NullPointerException.class)
     public void assertValueOfSchemaPathFailure() {
         SystemSchemaBuilderRule.valueOf(new MySQLDatabaseType().getType(), "test");
     }
diff --git a/shardingsphere-infra/shardingsphere-infra-merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/stream/StreamMergedResult.java b/shardingsphere-infra/shardingsphere-infra-merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/stream/StreamMergedResult.java
index b92f992ef1b..3cfbd7f3c39 100644
--- a/shardingsphere-infra/shardingsphere-infra-merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/stream/StreamMergedResult.java
+++ b/shardingsphere-infra/shardingsphere-infra-merge/src/main/java/org/apache/shardingsphere/infra/merge/result/impl/stream/StreamMergedResult.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.infra.merge.result.impl.stream;
 import lombok.Setter;
 import org.apache.shardingsphere.infra.executor.sql.execute.result.query.QueryResult;
 import org.apache.shardingsphere.infra.merge.result.MergedResult;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 
 import java.io.InputStream;
 import java.sql.SQLException;
@@ -36,9 +37,7 @@ public abstract class StreamMergedResult implements MergedResult {
     private boolean wasNull;
     
     protected final QueryResult getCurrentQueryResult() throws SQLException {
-        if (null == currentQueryResult) {
-            throw new SQLException("Current ResultSet is null, ResultSet perhaps end of next.");
-        }
+        ShardingSpherePreconditions.checkNotNull(currentQueryResult, new SQLException("Current ResultSet is null, ResultSet perhaps end of next."));
         return currentQueryResult;
     }
     
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditions.java b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditions.java
index a5d84cf18fb..fa08bf8c37f 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditions.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/main/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditions.java
@@ -32,7 +32,7 @@ public final class ShardingSpherePreconditions {
     
     /**
      * Ensures the truth of an expression involving the state of the calling instance.
-     * 
+     *
      * @param expectedExpression expected expression
      * @param exceptionIfUnexpected exception thrown if expression is unexpected
      */
@@ -92,4 +92,17 @@ public final class ShardingSpherePreconditions {
             throw exceptionIfUnexpected;
         }
     }
+    
+    /**
+     * Ensures that an object reference passed as a parameter to the calling method is not null.
+     *
+     * @param reference object reference to be checked
+     * @param exceptionIfUnexpected exception thrown if object is null
+     * @throws SQLException SQL exception
+     */
+    public static void checkNotNull(final Object reference, final SQLException exceptionIfUnexpected) throws SQLException {
+        if (null == reference) {
+            throw exceptionIfUnexpected;
+        }
+    }
 }
diff --git a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java
index 48aa4cea7f6..b8f05d19561 100644
--- a/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-util/src/test/java/org/apache/shardingsphere/infra/util/exception/ShardingSpherePreconditionsTest.java
@@ -78,4 +78,15 @@ public final class ShardingSpherePreconditionsTest {
     public void assertCheckNotNullToNotThrowInternalException() throws ShardingSphereInternalException {
         ShardingSpherePreconditions.checkNotNull(new Object(), new ShardingSphereInternalExceptionFixture("message"));
     }
+    
+    @Test(expected = SQLException.class)
+    public void assertCheckNotNullToThrowsSQLException() throws SQLException {
+        ShardingSpherePreconditions.checkNotNull(null, new SQLException("message"));
+    }
+    
+    @SuppressWarnings("ObviousNullCheck")
+    @Test
+    public void assertCheckNotNullToNotThrowSQLException() throws SQLException {
+        ShardingSpherePreconditions.checkNotNull(new Object(), new SQLException("message"));
+    }
 }
diff --git a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
index dd49dcd9a39..cfab4708ad8 100644
--- a/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
+++ b/shardingsphere-jdbc/shardingsphere-jdbc-core/src/main/java/org/apache/shardingsphere/driver/jdbc/core/datasource/metadata/ShardingSphereDatabaseMetaData.java
@@ -200,17 +200,13 @@ public final class ShardingSphereDatabaseMetaData extends AdaptedDatabaseMetaDat
     }
     
     private String getActualTableNamePattern(final String tableNamePattern) {
-        if (null == tableNamePattern) {
-            return null;
-        }
-        return findDataNodeContainedRule().filter(optional -> optional.findFirstActualTable(tableNamePattern).isPresent()).map(optional -> "%" + tableNamePattern + "%").orElse(tableNamePattern);
+        return null == tableNamePattern
+                ? null
+                : findDataNodeContainedRule().filter(optional -> optional.findFirstActualTable(tableNamePattern).isPresent()).map(optional -> "%" + tableNamePattern + "%").orElse(tableNamePattern);
     }
     
     private String getActualTable(final String catalog, final String table) {
-        if (null == table) {
-            return null;
-        }
-        return findDataNodeContainedRule().map(each -> findActualTable(each, catalog, table).orElse(table)).orElse(table);
+        return null == table ? null : findDataNodeContainedRule().map(each -> findActualTable(each, catalog, table).orElse(table)).orElse(table);
     }
     
     private Optional<String> findActualTable(final DataNodeContainedRule dataNodeContainedRule, final String catalog, final String table) {
diff --git a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
index d0227513fd9..56f35d64f43 100644
--- a/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
+++ b/shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/checker/AuthorityChecker.java
@@ -57,10 +57,7 @@ public final class AuthorityChecker implements SQLChecker<AuthorityRule> {
     
     @Override
     public boolean check(final String databaseName, final Grantee grantee, final AuthorityRule rule) {
-        if (null == grantee) {
-            return true;
-        }
-        return rule.findPrivileges(grantee).map(optional -> optional.hasPrivileges(databaseName)).orElse(false);
+        return null == grantee || rule.findPrivileges(grantee).map(optional -> optional.hasPrivileges(databaseName)).orElse(false);
     }
     
     @Override
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
index cb38fa617be..aa2eb0106f3 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/IntegerPrimaryKeyPosition.java
@@ -53,9 +53,6 @@ public final class IntegerPrimaryKeyPosition extends PrimaryKeyPosition<Long> im
     
     @Override
     public int compareTo(final IntegerPrimaryKeyPosition position) {
-        if (null == position) {
-            return 1;
-        }
-        return Long.compare(beginValue, position.beginValue);
+        return null == position ? 1 : Long.compare(beginValue, position.beginValue);
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
index 948d4ec0b92..f105f489d2a 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/ingest/position/StringPrimaryKeyPosition.java
@@ -43,9 +43,6 @@ public final class StringPrimaryKeyPosition extends PrimaryKeyPosition<String> i
     
     @Override
     public int compareTo(final StringPrimaryKeyPosition position) {
-        if (null == position) {
-            return 1;
-        }
-        return beginValue.compareTo(position.getBeginValue());
+        return null == position ? 1 : beginValue.compareTo(position.getBeginValue());
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobItemIncrementalTasksProgress.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobItemIncrementalTasksProgress.java
index 837832a40f8..ef63298a022 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobItemIncrementalTasksProgress.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-api/src/main/java/org/apache/shardingsphere/data/pipeline/api/job/progress/JobItemIncrementalTasksProgress.java
@@ -39,7 +39,7 @@ public final class JobItemIncrementalTasksProgress {
      * @return incremental position
      */
     public Optional<IngestPosition<?>> getIncrementalPosition() {
-        return null != incrementalTaskProgress ? Optional.of(incrementalTaskProgress.getPosition()) : Optional.empty();
+        return null == incrementalTaskProgress ? Optional.empty() : Optional.of(incrementalTaskProgress.getPosition());
     }
     
     /**
@@ -48,9 +48,6 @@ public final class JobItemIncrementalTasksProgress {
      * @return latest active time, <code>0</code> means there is no activity
      */
     public long getIncrementalLatestActiveTimeMillis() {
-        if (null == incrementalTaskProgress) {
-            return 0L;
-        }
-        return incrementalTaskProgress.getIncrementalTaskDelay().getLatestActiveTimeMillis();
+        return null == incrementalTaskProgress ? 0L : incrementalTaskProgress.getIncrementalTaskDelay().getLatestActiveTimeMillis();
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
index c82e23ef84d..f57cc68e7cc 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/api/impl/AbstractPipelineJobAPIImpl.java
@@ -230,9 +230,7 @@ public abstract class AbstractPipelineJobAPIImpl implements PipelineJobAPI {
     
     protected final JobConfigurationPOJO getElasticJobConfigPOJO(final String jobId) {
         JobConfigurationPOJO result = PipelineAPIFactory.getJobConfigurationAPI().getJobConfiguration(jobId);
-        if (null == result) {
-            throw new PipelineJobNotFoundException(jobId);
-        }
+        Preconditions.checkNotNull(result, new PipelineJobNotFoundException(jobId));
         return result;
     }
     
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
index 849fa41fbab..ef927898a20 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/check/consistency/algorithm/DataMatchDataConsistencyCalculateAlgorithm.java
@@ -131,9 +131,8 @@ public final class DataMatchDataConsistencyCalculateAlgorithm extends AbstractSt
                 : logicTableName.toLowerCase());
         if (null == parameter.getPreviousCalculatedResult()) {
             return firstSQLCache.computeIfAbsent(cacheKey, s -> sqlBuilder.buildChunkedQuerySQL(schemaName, logicTableName, uniqueKey, true));
-        } else {
-            return laterSQLCache.computeIfAbsent(cacheKey, s -> sqlBuilder.buildChunkedQuerySQL(schemaName, logicTableName, uniqueKey, false));
         }
+        return laterSQLCache.computeIfAbsent(cacheKey, s -> sqlBuilder.buildChunkedQuerySQL(schemaName, logicTableName, uniqueKey, false));
     }
     
     @Override
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
index d5cc6d4b12e..955f00d8f4a 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/core/job/PipelineJobIdUtils.java
@@ -17,6 +17,7 @@
 
 package org.apache.shardingsphere.data.pipeline.core.job;
 
+import com.google.common.base.Preconditions;
 import org.apache.shardingsphere.data.pipeline.api.job.JobType;
 import org.apache.shardingsphere.data.pipeline.api.job.PipelineJobId;
 
@@ -51,9 +52,7 @@ public final class PipelineJobIdUtils {
         }
         String typeCode = jobId.substring(1, 3);
         JobType result = JobType.valueOfByCode(typeCode);
-        if (null == result) {
-            throw new IllegalArgumentException("Could not get JobType by '" + typeCode + "', jobId: " + jobId);
-        }
+        Preconditions.checkNotNull(result, "Can not get job type by `%s`, job ID is `%s`", typeCode, jobId);
         return result;
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
index e1f1e62dc49..a26060e405e 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-core/src/main/java/org/apache/shardingsphere/data/pipeline/scenario/migration/MigrationJobAPIImpl.java
@@ -447,11 +447,10 @@ public final class MigrationJobAPIImpl extends AbstractPipelineJobAPIImpl implem
         StandardPipelineDataSourceConfiguration sourceDataSourceConfig = new StandardPipelineDataSourceConfiguration(sourceDataSourceProps);
         DatabaseType sourceDatabaseType = sourceDataSourceConfig.getDatabaseType();
         result.setSourceDatabaseType(sourceDatabaseType.getType());
-        if (null == parameter.getSourceSchemaName() && sourceDatabaseType.isSchemaAvailable()) {
-            result.setSourceSchemaName(PipelineSchemaTableUtil.getDefaultSchema(sourceDataSourceConfig));
-        } else {
-            result.setSourceSchemaName(parameter.getSourceSchemaName());
-        }
+        String sourceSchemaName = null == parameter.getSourceSchemaName() && sourceDatabaseType.isSchemaAvailable()
+                ? PipelineSchemaTableUtil.getDefaultSchema(sourceDataSourceConfig)
+                : parameter.getSourceSchemaName();
+        result.setSourceSchemaName(sourceSchemaName);
         result.setSourceTableName(parameter.getSourceTableName());
         Map<String, Map<String, Object>> targetDataSourceProperties = new HashMap<>();
         ShardingSphereDatabase targetDatabase = PipelineContext.getContextManager().getMetaDataContexts().getMetaData().getDatabase(parameter.getTargetDatabaseName());
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
index 6fa482e8607..4735eb4a017 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-mysql/src/main/java/org/apache/shardingsphere/data/pipeline/mysql/ingest/binlog/BinlogPosition.java
@@ -40,10 +40,7 @@ public final class BinlogPosition implements IngestPosition<BinlogPosition> {
     
     @Override
     public int compareTo(final BinlogPosition position) {
-        if (null == position) {
-            return 1;
-        }
-        return Long.compare(toLong(), position.toLong());
+        return null == position ? 1 : Long.compare(toLong(), position.toLong());
     }
     
     private long toLong() {
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalPosition.java b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalPosition.java
index 85472dfb9e8..15631f121ff 100644
--- a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalPosition.java
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/java/org/apache/shardingsphere/data/pipeline/postgresql/ingest/wal/WalPosition.java
@@ -33,10 +33,7 @@ public final class WalPosition implements IngestPosition<WalPosition> {
     
     @Override
     public int compareTo(final WalPosition position) {
-        if (null == position) {
-            return 1;
-        }
-        return Long.compare(logSequenceNumber.asLong(), position.logSequenceNumber.asLong());
+        return null == position ? 1 : Long.compare(logSequenceNumber.asLong(), position.logSequenceNumber.asLong());
     }
     
     @Override
diff --git a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/ddl/SingleTableDropSchemaMetadataValidator.java b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/ddl/SingleTableDropSchemaMetadataValidator.java
index a24c4953b8f..41a35c565cc 100644
--- a/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/ddl/SingleTableDropSchemaMetadataValidator.java
+++ b/shardingsphere-kernel/shardingsphere-single-table/shardingsphere-single-table-core/src/main/java/org/apache/shardingsphere/singletable/route/validator/ddl/SingleTableDropSchemaMetadataValidator.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.singletable.route.validator.ddl;
 import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.metadata.database.ShardingSphereDatabase;
 import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import org.apache.shardingsphere.singletable.exception.DropNotEmptySchemaException;
 import org.apache.shardingsphere.singletable.exception.SchemaNotFoundException;
 import org.apache.shardingsphere.singletable.route.validator.SingleTableMetadataValidator;
@@ -39,12 +40,8 @@ public final class SingleTableDropSchemaMetadataValidator implements SingleTable
         for (IdentifierValue each : sqlStatementContext.getSqlStatement().getSchemaNames()) {
             String schemaName = each.getValue();
             ShardingSphereSchema schema = database.getSchema(schemaName);
-            if (null == schema) {
-                throw new SchemaNotFoundException(schemaName);
-            }
-            if (!containsCascade && !schema.getAllTableNames().isEmpty()) {
-                throw new DropNotEmptySchemaException(schemaName);
-            }
+            ShardingSpherePreconditions.checkNotNull(schema, new SchemaNotFoundException(schemaName));
+            ShardingSpherePreconditions.checkState(containsCascade || schema.getAllTableNames().isEmpty(), new DropNotEmptySchemaException(schemaName));
         }
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/resultset/FederationResultSet.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/resultset/FederationResultSet.java
index a834fba66e4..613f99418cd 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/resultset/FederationResultSet.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-executor/shardingsphere-sql-federation-advanced-executor/src/main/java/org/apache/shardingsphere/sqlfederation/advanced/resultset/FederationResultSet.java
@@ -25,6 +25,7 @@ import org.apache.shardingsphere.infra.binder.statement.SQLStatementContext;
 import org.apache.shardingsphere.infra.binder.statement.dml.SelectStatementContext;
 import org.apache.shardingsphere.infra.executor.sql.execute.result.query.impl.driver.jdbc.type.util.ResultSetUtil;
 import org.apache.shardingsphere.infra.metadata.database.schema.decorator.model.ShardingSphereSchema;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 
 import java.io.InputStream;
 import java.io.Reader;
@@ -443,11 +444,9 @@ public final class FederationResultSet extends AbstractUnsupportedOperationResul
         return getString(columnLabel);
     }
     
-    private Integer getIndexFromColumnLabelAndIndexMap(final String columnLabel) throws SQLFeatureNotSupportedException {
+    private Integer getIndexFromColumnLabelAndIndexMap(final String columnLabel) throws SQLException {
         Integer result = columnLabelAndIndexMap.get(columnLabel.toLowerCase());
-        if (null == result) {
-            throw new SQLFeatureNotSupportedException(String.format("can't get index from columnLabel[%s].", columnLabel));
-        }
+        ShardingSpherePreconditions.checkNotNull(result, new SQLFeatureNotSupportedException(String.format("can't get index from columnLabel[%s].", columnLabel)));
         return result;
     }
     
diff --git a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/SubqueryExpressionConverter.java b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/SubqueryExpressionConverter.java
index 6b9d28b3e58..f4c735d8336 100644
--- a/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/SubqueryExpressionConverter.java
+++ b/shardingsphere-kernel/shardingsphere-sql-federation/shardingsphere-sql-federation-optimizer/src/main/java/org/apache/shardingsphere/sqlfederation/optimizer/converter/segment/expression/impl/SubqueryExpressionConverter.java
@@ -31,9 +31,6 @@ public final class SubqueryExpressionConverter implements SQLSegmentConverter<Su
     
     @Override
     public Optional<SqlNode> convert(final SubqueryExpressionSegment expression) {
-        if (null == expression) {
-            return Optional.empty();
-        }
-        return Optional.of(new SelectStatementConverter().convert(expression.getSubquery().getSelect()));
+        return null == expression ? Optional.empty() : Optional.of(new SelectStatementConverter().convert(expression.getSubquery().getSelect()));
     }
 }
diff --git a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-parser/src/main/java/org/apache/shardingsphere/traffic/distsql/parser/core/TrafficDistSQLStatementVisitor.java b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-parser/src/main/java/org/apache/shardingsphere/traffic/distsql/parser/core/TrafficDistSQLStatementVisitor.java
index c97d337734b..6f8a99850e9 100644
--- a/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-parser/src/main/java/org/apache/shardingsphere/traffic/distsql/parser/core/TrafficDistSQLStatementVisitor.java
+++ b/shardingsphere-kernel/shardingsphere-traffic/shardingsphere-traffic-distsql/shardingsphere-traffic-distsql-parser/src/main/java/org/apache/shardingsphere/traffic/distsql/parser/core/TrafficDistSQLStatementVisitor.java
@@ -70,18 +70,12 @@ public final class TrafficDistSQLStatementVisitor extends TrafficDistSQLStatemen
     }
     
     private Collection<String> buildLabels(final LabelDefinitionContext labelDefinition) {
-        if (null == labelDefinition) {
-            return Collections.emptyList();
-        }
-        return labelDefinition.label().stream().map(this::getIdentifierValue).collect(Collectors.toList());
+        return null == labelDefinition ? Collections.emptyList() : labelDefinition.label().stream().map(this::getIdentifierValue).collect(Collectors.toList());
     }
     
     @Override
     public ASTNode visitLoadBalancerDefinition(final LoadBalancerDefinitionContext ctx) {
-        if (null == ctx) {
-            return null;
-        }
-        return visit(ctx.algorithmDefinition());
+        return null == ctx ? null : visit(ctx.algorithmDefinition());
     }
     
     @Override
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSou [...]
index 9eb38ab2fe3..72db00c6435 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-core/src/main/java/org/apache/shardingsphere/transaction/xa/jta/datasource/swapper/DataSourceSwapper.java
@@ -20,6 +20,7 @@ package org.apache.shardingsphere.transaction.xa.jta.datasource.swapper;
 import com.google.common.base.CaseFormat;
 import lombok.RequiredArgsConstructor;
 import lombok.SneakyThrows;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
 import org.apache.shardingsphere.transaction.xa.jta.datasource.properties.XADataSourceDefinition;
 import org.apache.shardingsphere.transaction.xa.jta.exception.XADataSourceInitializeException;
 
@@ -68,9 +69,7 @@ public final class DataSourceSwapper {
                 exceptions.add(ex);
             }
         }
-        if (null == result && !exceptions.isEmpty()) {
-            throw new XADataSourceInitializeException(xaDataSourceDefinition);
-        }
+        ShardingSpherePreconditions.checkState(null != result || exceptions.isEmpty(), new XADataSourceInitializeException(xaDataSourceDefinition));
         return result;
     }
     
diff --git a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/DataSourceXAResourceRecoveryHelper.java b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction- [...]
index 59d2f03702a..8d935cdc778 100644
--- a/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/DataSourceXAResourceRecoveryHelper.java
+++ b/shardingsphere-kernel/shardingsphere-transaction/shardingsphere-transaction-type/shardingsphere-transaction-xa/shardingsphere-transaction-xa-provider/shardingsphere-transaction-xa-narayana/src/main/java/org/apache/shardingsphere/transaction/xa/narayana/manager/DataSourceXAResourceRecoveryHelper.java
@@ -18,6 +18,7 @@
 package org.apache.shardingsphere.transaction.xa.narayana.manager;
 
 import com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper;
+import com.google.common.base.Preconditions;
 import lombok.extern.slf4j.Slf4j;
 
 import javax.sql.XAConnection;
@@ -94,10 +95,7 @@ public final class DataSourceXAResourceRecoveryHelper implements XAResourceRecov
     }
     
     private XAConnection getXaConnection() throws SQLException {
-        if (null == user && null == password) {
-            return xaDataSource.getXAConnection();
-        }
-        return xaDataSource.getXAConnection(user, password);
+        return null == user && null == password ? xaDataSource.getXAConnection() : xaDataSource.getXAConnection(user, password);
     }
     
     @Override
@@ -168,9 +166,7 @@ public final class DataSourceXAResourceRecoveryHelper implements XAResourceRecov
     }
     
     private XAResource getDelegate() {
-        if (null == delegate) {
-            throw new IllegalStateException("Connection has not been opened");
-        }
+        Preconditions.checkNotNull(delegate, "Connection has not been opened");
         return delegate;
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/DatabaseRequiredBackendHandler.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/DatabaseRequiredBackendHandler.java
index 523c0bd34ea..a14c3a27f2c 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/DatabaseRequiredBackendHandler.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/DatabaseRequiredBackendHandler.java
@@ -19,9 +19,10 @@ package org.apache.shardingsphere.proxy.backend.handler;
 
 import lombok.Getter;
 import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.dialect.exception.syntax.database.NoDatabaseSelectedException;
 import org.apache.shardingsphere.dialect.exception.syntax.database.UnknownDatabaseException;
+import org.apache.shardingsphere.infra.util.exception.ShardingSpherePreconditions;
+import org.apache.shardingsphere.proxy.backend.context.ProxyContext;
 import org.apache.shardingsphere.proxy.backend.response.header.ResponseHeader;
 import org.apache.shardingsphere.proxy.backend.session.ConnectionSession;
 import org.apache.shardingsphere.sql.parser.sql.common.segment.generic.DatabaseSegment;
@@ -59,11 +60,7 @@ public abstract class DatabaseRequiredBackendHandler<T extends SQLStatement> imp
     }
     
     private void checkDatabaseName(final String databaseName) {
-        if (null == databaseName) {
-            throw new NoDatabaseSelectedException();
-        }
-        if (!ProxyContext.getInstance().databaseExists(databaseName)) {
-            throw new UnknownDatabaseException(databaseName);
-        }
+        ShardingSpherePreconditions.checkNotNull(databaseName, new NoDatabaseSelectedException());
+        ShardingSpherePreconditions.checkState(ProxyContext.getInstance().databaseExists(databaseName), new UnknownDatabaseException(databaseName));
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/converter/InventoryIncrementalProcessConfigurationSegmentConverter.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/converter/InventoryIncrementalProcessConfigurationSegmentConverter.java
index 958fe21ac4d..1eb533c1c0d 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/converter/InventoryIncrementalProcessConfigurationSegmentConverter.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/ral/updatable/converter/InventoryIncrementalProcessConfigurationSegmentConverter.java
@@ -47,23 +47,16 @@ public final class InventoryIncrementalProcessConfigurationSegmentConverter {
     }
     
     private static PipelineReadConfiguration convertToReadConfiguration(final ReadOrWriteSegment readSegment) {
-        if (null == readSegment) {
-            return null;
-        }
-        return new PipelineReadConfiguration(readSegment.getWorkerThread(), readSegment.getBatchSize(), readSegment.getShardingSize(), convertToAlgorithm(readSegment.getRateLimiter()));
+        return null == readSegment
+                ? null
+                : new PipelineReadConfiguration(readSegment.getWorkerThread(), readSegment.getBatchSize(), readSegment.getShardingSize(), convertToAlgorithm(readSegment.getRateLimiter()));
     }
     
     private static PipelineWriteConfiguration convertToWriteConfiguration(final ReadOrWriteSegment writeSegment) {
-        if (null == writeSegment) {
-            return null;
-        }
-        return new PipelineWriteConfiguration(writeSegment.getWorkerThread(), writeSegment.getBatchSize(), convertToAlgorithm(writeSegment.getRateLimiter()));
+        return null == writeSegment ? null : new PipelineWriteConfiguration(writeSegment.getWorkerThread(), writeSegment.getBatchSize(), convertToAlgorithm(writeSegment.getRateLimiter()));
     }
     
     private static AlgorithmConfiguration convertToAlgorithm(final AlgorithmSegment segment) {
-        if (null == segment) {
-            return null;
-        }
-        return new AlgorithmConfiguration(segment.getName(), segment.getProps());
+        return null == segment ? null : new AlgorithmConfiguration(segment.getName(), segment.getProps());
     }
 }
diff --git a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/CountSingleTableRuleQueryResultSet.java b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/CountSingleTableRuleQueryResultSet.java
index fe63c36334b..d98d73c0cf0 100644
--- a/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/CountSingleTableRuleQueryResultSet.java
+++ b/shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/handler/distsql/rql/rule/CountSingleTableRuleQueryResultSet.java
@@ -62,10 +62,9 @@ public final class CountSingleTableRuleQueryResultSet implements DatabaseDistSQL
     private LinkedList<Object> buildRow(final LinkedList<Object> value, final String databaseName, final int count) {
         if (null == value) {
             return new LinkedList<>(Arrays.asList(databaseName, count));
-        } else {
-            value.set(1, (Integer) value.get(1) + count);
-            return value;
         }
+        value.set(1, (Integer) value.get(1) + count);
+        return value;
     }
     
     @Override
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
index 3250cbca3be..8ed1054ee66 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-dialect/shardingsphere-sql-parser-oracle/src/main/java/org/apache/shardingsphere/sql/parser/oracle/visitor/statement/impl/OracleStatementSQLVisitor.java
@@ -515,10 +515,7 @@ public abstract class OracleStatementSQLVisitor extends OracleStatementBaseVisit
     }
     
     private Collection<ExpressionSegment> getExpressions(final AggregationFunctionContext ctx) {
-        if (null == ctx.expr()) {
-            return Collections.emptyList();
-        }
-        return Collections.singletonList((ExpressionSegment) visit(ctx.expr()));
+        return null == ctx.expr() ? Collections.emptyList() : Collections.singletonList((ExpressionSegment) visit(ctx.expr()));
     }
     
     private String getDistinctExpression(final AggregationFunctionContext ctx) {
diff --git a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/WhereExtractUtil.java b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/WhereExtractUtil.java
index a6bc7c6f127..c20403a2421 100644
--- a/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/WhereExtractUtil.java
+++ b/shardingsphere-sql-parser/shardingsphere-sql-parser-statement/src/main/java/org/apache/shardingsphere/sql/parser/sql/common/util/WhereExtractUtil.java
@@ -43,10 +43,7 @@ public final class WhereExtractUtil {
      * @return join where segment collection
      */
     public static Collection<WhereSegment> getJoinWhereSegments(final SelectStatement selectStatement) {
-        if (null == selectStatement.getFrom()) {
-            return Collections.emptyList();
-        }
-        return getJoinWhereSegments(selectStatement.getFrom());
+        return null == selectStatement.getFrom() ? Collections.emptyList() : getJoinWhereSegments(selectStatement.getFrom());
     }
     
     private static Collection<WhereSegment> getJoinWhereSegments(final TableSegment tableSegment) {
diff --git a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/framework/container/config/mysql/MySQLContainerConfigurationFactory.java b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
index d604fc17ee2..52be173eb2c 100644
--- a/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
+++ b/shardingsphere-test/shardingsphere-integration-test/shardingsphere-integration-test-ha/src/test/java/org/apache/shardingsphere/test/integration/ha/framework/container/config/mysql/MySQLContainerConfigurationFactory.java
@@ -46,7 +46,7 @@ public final class MySQLContainerConfigurationFactory {
      */
     public static List<StorageContainerConfiguration> newInstance(final String scenario, final DatabaseType databaseType) {
         Integer containerQuantity = HAContainerUtil.loadContainerRawNamesAndQuantity(scenario).get(databaseType.getType().toLowerCase());
-        if (containerQuantity == null) {
+        if (null == containerQuantity) {
             return getDefaultConfiguration(databaseType);
         }
         if (1 == containerQuantity) {
diff --git a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
index 351348b3ca8..7e5e5c5f4e7 100644
--- a/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
+++ b/shardingsphere-test/shardingsphere-rewrite-test/src/test/java/org/apache/shardingsphere/sharding/rewrite/parameterized/engine/parameter/SQLRewriteEngineTestParametersBuilder.java
@@ -117,7 +117,7 @@ public final class SQLRewriteEngineTestParametersBuilder {
         } else {
             return Splitter.on(",").trimResults().splitToList(inputParameters).stream().map(each -> {
                 Object result = Ints.tryParse(each);
-                return result == null ? each : result;
+                return null == result ? each : result;
             }).collect(Collectors.toList());
         }
     }