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

benjobs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-streampark.git


The following commit(s) were added to refs/heads/dev by this push:
     new 50c45a681 [ISSUE-3057][Improve] Improve streampark-common module base 
on [3.7 Code Comments Rule] (#3413)
50c45a681 is described below

commit 50c45a681a55a91fe9dc1783f45952423ebe89a2
Author: Yuepeng Pan <[email protected]>
AuthorDate: Thu Dec 21 08:11:34 2023 +0800

    [ISSUE-3057][Improve] Improve streampark-common module base on [3.7 Code 
Comments Rule] (#3413)
---
 .../streampark/common/enums/ApplicationType.java   |  5 +-
 .../streampark/common/enums/ClusterState.java      | 25 +++++++-
 .../common/enums/FlinkDevelopmentMode.java         |  9 ++-
 .../common/enums/FlinkExecutionMode.java           | 69 +++++++++++++++++++++-
 .../common/enums/FlinkK8sRestExposedType.java      |  4 ++
 .../streampark/common/enums/FlinkRestoreMode.java  |  4 ++
 .../common/enums/FlinkSqlValidationFailedType.java |  5 ++
 .../streampark/common/enums/ResolveOrder.java      |  1 +
 .../apache/streampark/common/enums/Semantic.java   |  1 +
 .../streampark/common/enums/StorageType.java       |  2 +
 .../streampark/common/util/ExceptionUtils.java     |  6 ++
 11 files changed, 125 insertions(+), 6 deletions(-)

diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
index f73b1a4b1..a46c10e5b 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ApplicationType.java
@@ -19,6 +19,7 @@ package org.apache.streampark.common.enums;
 
 import javax.annotation.Nonnull;
 
+/** Application type enum. */
 public enum ApplicationType {
 
   /** Unknown type replace null */
@@ -44,16 +45,18 @@ public enum ApplicationType {
     this.name = name;
   }
 
+  /** Get the type value of the enum. */
   public int getType() {
     return type;
   }
 
+  /** Get the name of application type. */
   @Nonnull
   public String getName() {
     return name;
   }
 
-  /** switch param use this, can't be null */
+  /** Try to resolve the given application type value into a known {@link 
ApplicationType} enum. */
   @Nonnull
   public static ApplicationType of(int type) {
     for (ApplicationType appType : ApplicationType.values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
index bf62ca5e4..d77cc914a 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ClusterState.java
@@ -20,7 +20,11 @@ package org.apache.streampark.common.enums;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
-/** @since 1.2.3 */
+/**
+ * Cluster state enum.
+ *
+ * @since 1.2.3
+ */
 public enum ClusterState {
 
   /** The cluster was just created but not started */
@@ -56,6 +60,12 @@ public enum ClusterState {
     this.state = state;
   }
 
+  /**
+   * Try to resolve the value into {@link ClusterState}.
+   *
+   * @param value the state value of potential cluster state.
+   * @return the parsed cluster state enum.
+   */
   @Nonnull
   public static ClusterState of(@Nullable Integer value) {
     for (ClusterState clusterState : values()) {
@@ -66,6 +76,12 @@ public enum ClusterState {
     return ClusterState.UNKNOWN;
   }
 
+  /**
+   * Try to resolve the name into {@link ClusterState}.
+   *
+   * @param name The name of potential cluster state.
+   * @return The parsed cluster state enum.
+   */
   @Nonnull
   public static ClusterState of(@Nullable String name) {
     for (ClusterState clusterState : values()) {
@@ -76,11 +92,18 @@ public enum ClusterState {
     return ClusterState.UNKNOWN;
   }
 
+  /** Get the state value of the current cluster state enum. */
   @Nonnull
   public Integer getState() {
     return state;
   }
 
+  /**
+   * Judge the given state enum whether is the running state.
+   *
+   * @param state The give state enum to judge.
+   * @return The result of the judging.
+   */
   public static boolean isRunning(@Nullable ClusterState state) {
     return RUNNING.equals(state);
   }
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
index 09c94fe37..fade6be9f 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkDevelopmentMode.java
@@ -20,6 +20,7 @@ package org.apache.streampark.common.enums;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+/** The flink deployment mode enum. */
 public enum FlinkDevelopmentMode {
 
   /** Unknown type replace null */
@@ -42,7 +43,12 @@ public enum FlinkDevelopmentMode {
     this.mode = mode;
   }
 
-  /** switch param use this, can't be null */
+  /**
+   * Try to resolve the mode value into {@link FlinkDevelopmentMode}.
+   *
+   * @param value The mode value of potential flink deployment mode.
+   * @return The parsed flink deployment mode.
+   */
   @Nonnull
   public static FlinkDevelopmentMode of(@Nullable Integer value) {
     for (FlinkDevelopmentMode flinkDevelopmentMode : values()) {
@@ -53,6 +59,7 @@ public enum FlinkDevelopmentMode {
     return FlinkDevelopmentMode.UNKNOWN;
   }
 
+  /** Get the mode value of the current {@link FlinkDevelopmentMode} enum. */
   @Nonnull
   public Integer getMode() {
     return mode;
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
index f7e17dd8c..e72d49ad7 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkExecutionMode.java
@@ -24,6 +24,7 @@ import javax.annotation.Nullable;
 
 import java.util.List;
 
+/** Flink execution mode enum. */
 public enum FlinkExecutionMode {
 
   /** Unknown Mode */
@@ -58,7 +59,12 @@ public enum FlinkExecutionMode {
     this.name = name;
   }
 
-  /** switch param use this, can't be null */
+  /**
+   * Try to resolve the mode value into {@link FlinkExecutionMode}.
+   *
+   * @param value The mode value of potential flink execution mode.
+   * @return The parsed flink execution mode enum.
+   */
   @Nonnull
   public static FlinkExecutionMode of(@Nullable Integer value) {
     for (FlinkExecutionMode mode : values()) {
@@ -69,6 +75,12 @@ public enum FlinkExecutionMode {
     return FlinkExecutionMode.UNKNOWN;
   }
 
+  /**
+   * Try to resolve the mode name into {@link FlinkExecutionMode}.
+   *
+   * @param name The mode name of potential flink execution mode.
+   * @return The parsed flink execution mode enum.
+   */
   @Nonnull
   public static FlinkExecutionMode of(@Nullable String name) {
     for (FlinkExecutionMode mode : values()) {
@@ -88,54 +100,105 @@ public enum FlinkExecutionMode {
     return name;
   }
 
+  /**
+   * Judge the given mode whether is yarn mode.
+   *
+   * @param mode The given mode.
+   * @return The judged result.
+   */
   public static boolean isYarnMode(@Nullable FlinkExecutionMode mode) {
     return YARN_PER_JOB == mode || YARN_APPLICATION == mode || YARN_SESSION == 
mode;
   }
 
-  // TODO: We'll inline this method back to the corresponding caller lines
-  //  after dropping the yarn perjob mode.
+  /**
+   * Judge the given mode whether is yarn per-job or application mode.
+   *
+   * @param mode The given mode.
+   * @return The judged result. TODO: We'll inline this method back to the 
corresponding caller
+   *     lines after dropping the yarn perjob mode.
+   */
   public static boolean isYarnPerJobOrAppMode(@Nullable FlinkExecutionMode 
mode) {
     return YARN_PER_JOB == mode || YARN_APPLICATION == mode;
   }
 
+  /**
+   * Judge the given mode whether is yarn session mode.
+   *
+   * @param mode The given mode.
+   * @return The judged result.
+   */
   public static boolean isYarnSessionMode(@Nullable FlinkExecutionMode mode) {
     return YARN_SESSION == mode;
   }
 
+  /**
+   * Judge the mode value whether is yarn execution mode.
+   *
+   * @param value The mode value of potential flink execution mode.
+   * @return The judged result.
+   */
   public static boolean isYarnMode(@Nullable Integer value) {
     return isYarnMode(of(value));
   }
 
+  /**
+   * Judge the mode value whether is k8s session execution mode.
+   *
+   * @param value The mode value of potential flink execution mode.
+   * @return The judged result.
+   */
   public static boolean isKubernetesSessionMode(@Nullable Integer value) {
     return KUBERNETES_NATIVE_SESSION == of(value);
   }
 
+  /**
+   * Judge the mode whether is k8s execution mode.
+   *
+   * @param mode The given flink execution mode.
+   * @return The judged result.
+   */
   public static boolean isKubernetesMode(@Nullable FlinkExecutionMode mode) {
     return KUBERNETES_NATIVE_SESSION == mode || KUBERNETES_NATIVE_APPLICATION 
== mode;
   }
 
+  /**
+   * Judge the mode value whether is k8s execution mode.
+   *
+   * @param value The mode value of potential flink execution mode.
+   * @return The judged result.
+   */
   public static boolean isKubernetesMode(@Nullable Integer value) {
     return isKubernetesMode(of(value));
   }
 
+  /**
+   * Judge the mode value whether is k8s application execution mode.
+   *
+   * @param value The mode value of potential flink execution mode.
+   * @return The judged result.
+   */
   public static boolean isKubernetesApplicationMode(@Nullable Integer value) {
     return KUBERNETES_NATIVE_APPLICATION == of(value);
   }
 
+  /** Get all k8s mode values into a list. */
   @Nonnull
   public static List<Integer> getKubernetesMode() {
     return Lists.newArrayList(
         KUBERNETES_NATIVE_SESSION.getMode(), 
KUBERNETES_NATIVE_APPLICATION.getMode());
   }
 
+  /** Judge the given flink execution mode whether is session execution mode. 
*/
   public static boolean isSessionMode(@Nullable FlinkExecutionMode mode) {
     return KUBERNETES_NATIVE_SESSION == mode || YARN_SESSION == mode;
   }
 
+  /** Judge the given flink execution mode value whether is remote execution 
mode. */
   public static boolean isRemoteMode(@Nullable Integer value) {
     return isRemoteMode(of(value));
   }
 
+  /** Judge the given flink execution mode whether is remote execution mode. */
   public static boolean isRemoteMode(@Nullable FlinkExecutionMode mode) {
     return REMOTE == mode;
   }
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
index c1fec9616..5aa5fea7c 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkK8sRestExposedType.java
@@ -41,6 +41,10 @@ public enum FlinkK8sRestExposedType {
     this.type = type;
   }
 
+  /**
+   * Try to resolve the given Flink K8s Rest-Exposed type value into a known 
{@link
+   * FlinkK8sRestExposedType} enum.
+   */
   @Nullable
   public static FlinkK8sRestExposedType of(@Nullable Integer value) {
     for (FlinkK8sRestExposedType order : values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
index 025c12fd6..c3ea4ca44 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkRestoreMode.java
@@ -22,6 +22,7 @@ import javax.annotation.Nullable;
 
 import java.util.Objects;
 
+/** Flink state restore mode enum. */
 public enum FlinkRestoreMode {
 
   /**
@@ -63,6 +64,9 @@ public enum FlinkRestoreMode {
     return this.toString();
   }
 
+  /**
+   * Try to resolve the given flink restore mode value into a known {@link 
FlinkRestoreMode} enum.
+   */
   @Nullable
   public static FlinkRestoreMode of(@Nullable Integer value) {
     for (FlinkRestoreMode flinkRestoreModeEnum : values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
index 8f750455b..d9dee5059 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/FlinkSqlValidationFailedType.java
@@ -19,6 +19,7 @@ package org.apache.streampark.common.enums;
 
 import javax.annotation.Nullable;
 
+/** Flink SQL validation failed type enum. */
 public enum FlinkSqlValidationFailedType {
 
   /** Basic test failed (such as null, etc.) */
@@ -42,6 +43,10 @@ public enum FlinkSqlValidationFailedType {
     this.failedType = failedType;
   }
 
+  /**
+   * Try to resolve the given flink SQL validation failed type value into a 
known {@link
+   * FlinkSqlValidationFailedType} enum.
+   */
   @Nullable
   public static FlinkSqlValidationFailedType of(Integer value) {
     for (FlinkSqlValidationFailedType type : values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
index ed800bc0a..d6b294b41 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/ResolveOrder.java
@@ -38,6 +38,7 @@ public enum ResolveOrder {
     this.order = order;
   }
 
+  /** Try to resolve the given resolve order value into a known {@link 
ResolveOrder} enum. */
   @Nullable
   public static ResolveOrder of(@Nullable Integer value) {
     for (ResolveOrder order : values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
index 655a9f85a..927777da0 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/Semantic.java
@@ -34,6 +34,7 @@ public enum Semantic {
   /** After the fault occurs, the counting results may be lost. */
   NONE;
 
+  /** Try to resolve the given semantic name into a known {@link Semantic}. */
   @Nullable
   public static Semantic of(@Nonnull String name) {
     for (Semantic semantic : Semantic.values()) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
index 7fe57ae18..a6b22ef46 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/enums/StorageType.java
@@ -22,6 +22,7 @@ import org.apache.commons.lang3.StringUtils;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
 
+/** Storage type enum. */
 public enum StorageType {
 
   /** hdfs */
@@ -41,6 +42,7 @@ public enum StorageType {
     return type;
   }
 
+  /** Try to resolve the given storage type identifier into a known {@link 
StorageType}. */
   @Nonnull
   public static StorageType of(@Nullable String identifier) {
     if (StringUtils.isBlank(identifier)) {
diff --git 
a/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
 
b/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
index 43d897f8e..40deb57b5 100644
--- 
a/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
+++ 
b/streampark-common/src/main/java/org/apache/streampark/common/util/ExceptionUtils.java
@@ -29,6 +29,12 @@ public class ExceptionUtils {
 
   private ExceptionUtils() {}
 
+  /**
+   * Stringify the exception object.
+   *
+   * @param throwable the target exception to stringify.
+   * @return the result of string-exception.
+   */
   @Nonnull
   public static String stringifyException(@Nullable Throwable throwable) {
     if (throwable == null) {

Reply via email to