瀏覽代碼

Replace '==' with Objects.equals() method (#310)

Signed-off-by: Chen Biao <biao.chen@zilliz.com>
Chen Biao 2 年之前
父節點
當前提交
b1cbf069b1

+ 6 - 4
src/main/java/io/milvus/param/collection/LoadCollectionParam.java

@@ -26,6 +26,8 @@ import io.milvus.param.ParamUtils;
 import lombok.Getter;
 import lombok.NonNull;
 
+import java.util.Objects;
+
 /**
  * Parameters for <code>loadCollection</code> interface.
  */
@@ -90,7 +92,7 @@ public class LoadCollectionParam {
         /**
          * Enable sync mode for load action.
          * With sync mode enabled, the client keeps waiting until all segments of the collection successfully loaded.
-         *
+         * <p>
          * If sync mode disabled, client returns at once after the loadCollection() is called.
          *
          * @param syncLoad <code>Boolean.TRUE</code> is sync mode, Boolean.FALSE is not
@@ -104,10 +106,10 @@ public class LoadCollectionParam {
         /**
          * Sets waiting interval in sync mode. With sync mode enabled, the client will constantly check collection load state by interval.
          * Interval must be greater than zero, and cannot be larger than Constant.MAX_WAITING_LOADING_INTERVAL.
-         * @see Constant
          *
          * @param milliseconds interval
          * @return <code>Builder</code>
+         * @see Constant
          */
         public Builder withSyncLoadWaitingInterval(@NonNull Long milliseconds) {
             this.syncLoadWaitingInterval = milliseconds;
@@ -117,10 +119,10 @@ public class LoadCollectionParam {
         /**
          * Sets timeout value for the sync mode.
          * Timeout value must be greater than zero, and cannot be greater than Constant.MAX_WAITING_LOADING_TIMEOUT.
-         * @see Constant
          *
          * @param seconds time out value for sync mode
          * @return <code>Builder</code>
+         * @see Constant
          */
         public Builder withSyncLoadWaitingTimeout(@NonNull Long seconds) {
             this.syncLoadWaitingTimeout = seconds;
@@ -146,7 +148,7 @@ public class LoadCollectionParam {
         public LoadCollectionParam build() throws ParamException {
             ParamUtils.CheckNullEmptyString(collectionName, "Collection name");
 
-            if (syncLoad == Boolean.TRUE) {
+            if (Objects.equals(syncLoad, Boolean.TRUE)) {
                 if (syncLoadWaitingInterval <= 0) {
                     throw new ParamException("Sync load waiting interval must be larger than zero");
                 } else if (syncLoadWaitingInterval > Constant.MAX_WAITING_LOADING_INTERVAL) {

+ 2 - 1
src/main/java/io/milvus/param/index/CreateIndexParam.java

@@ -30,6 +30,7 @@ import org.apache.commons.lang3.StringUtils;
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * Parameters for <code>createIndex</code> interface.
@@ -219,7 +220,7 @@ public class CreateIndexParam {
                 throw new ParamException("Metric type is required");
             }
 
-            if (syncMode == Boolean.TRUE) {
+            if (Objects.equals(syncMode, Boolean.TRUE)) {
                 if (syncWaitingInterval <= 0) {
                     throw new ParamException("Sync index waiting interval must be larger than zero");
                 } else if (syncWaitingInterval > Constant.MAX_WAITING_INDEX_INTERVAL) {

+ 5 - 4
src/main/java/io/milvus/param/partition/LoadPartitionsParam.java

@@ -28,6 +28,7 @@ import lombok.Getter;
 import lombok.NonNull;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * Parameters for <code>loadPartition</code> interface.
@@ -120,7 +121,7 @@ public class LoadPartitionsParam {
         /**
          * Enables sync mode for load action.
          * With sync mode enabled, the client keeps waiting until all segments of the partition are successfully loaded.
-         *
+         * <p>
          * Without sync mode disabled, client returns at once after the loadPartitions() is called.
          *
          * @param syncLoad <code>Boolean.TRUE</code> is sync mode, Boolean.FALSE is not
@@ -134,10 +135,10 @@ public class LoadPartitionsParam {
         /**
          * Sets the waiting interval for sync mode. In sync mode, the client constantly checks partition load state by interval.
          * Interval must be greater than zero, and cannot be greater than Constant.MAX_WAITING_LOADING_INTERVAL.
-         * @see Constant
          *
          * @param milliseconds interval
          * @return <code>Builder</code>
+         * @see Constant
          */
         public Builder withSyncLoadWaitingInterval(@NonNull Long milliseconds) {
             this.syncLoadWaitingInterval = milliseconds;
@@ -147,10 +148,10 @@ public class LoadPartitionsParam {
         /**
          * Sets the timeout value for sync mode.
          * Timeout value must be greater than zero, and cannot be greater than Constant.MAX_WAITING_LOADING_TIMEOUT.
-         * @see Constant
          *
          * @param seconds time out value for sync mode
          * @return <code>Builder</code>
+         * @see Constant
          */
         public Builder withSyncLoadWaitingTimeout(@NonNull Long seconds) {
             this.syncLoadWaitingTimeout = seconds;
@@ -184,7 +185,7 @@ public class LoadPartitionsParam {
                 ParamUtils.CheckNullEmptyString(name, "Partition name");
             }
 
-            if (syncLoad == Boolean.TRUE) {
+            if (Objects.equals(syncLoad, Boolean.TRUE)) {
                 if (syncLoadWaitingInterval <= 0) {
                     throw new ParamException("Sync load waiting interval must be larger than zero");
                 } else if (syncLoadWaitingInterval > Constant.MAX_WAITING_LOADING_INTERVAL) {