Skip to content

Commit

Permalink
[Improve] Unified Naming Rules for Enumeration Classes (#3133) (#3175)
Browse files Browse the repository at this point in the history
* [Improve] Unified Naming Rules for Enumeration Classes (#3133)
  • Loading branch information
xsymin authored Sep 24, 2023
1 parent 436b9f3 commit 2274d55
Show file tree
Hide file tree
Showing 187 changed files with 1,313 additions and 1,298 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.streampark.common.enums;

public enum ApplicationType {
public enum ApplicationTypeEnum {

/** StreamPark Flink */
STREAMPARK_FLINK(1, "StreamPark Flink"),
Expand All @@ -34,7 +34,7 @@ public enum ApplicationType {
private final int type;
private final String name;

ApplicationType(int type, String name) {
ApplicationTypeEnum(int type, String name) {
this.type = type;
this.name = name;
}
Expand All @@ -47,8 +47,8 @@ public String getName() {
return name;
}

public static ApplicationType of(int type) {
for (ApplicationType appType : ApplicationType.values()) {
public static ApplicationTypeEnum of(int type) {
for (ApplicationTypeEnum appType : ApplicationTypeEnum.values()) {
if (appType.getType() == type) {
return appType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.streampark.common.enums;

/** @since 1.2.3 */
public enum ClusterState {
public enum ClusterStateEnum {

/** The cluster was just created but not started */
CREATED(0),
Expand Down Expand Up @@ -49,33 +49,33 @@ public enum ClusterState {

private final Integer state;

ClusterState(Integer state) {
ClusterStateEnum(Integer state) {
this.state = state;
}

public static ClusterState of(Integer value) {
for (ClusterState clusterState : values()) {
if (clusterState.state.equals(value)) {
return clusterState;
public static ClusterStateEnum of(Integer value) {
for (ClusterStateEnum clusterStateEnum : values()) {
if (clusterStateEnum.state.equals(value)) {
return clusterStateEnum;
}
}
return ClusterState.UNKNOWN;
return ClusterStateEnum.UNKNOWN;
}

public static ClusterState of(String name) {
for (ClusterState clusterState : values()) {
if (clusterState.name().equals(name)) {
return clusterState;
public static ClusterStateEnum of(String name) {
for (ClusterStateEnum clusterStateEnum : values()) {
if (clusterStateEnum.name().equals(name)) {
return clusterStateEnum;
}
}
return ClusterState.UNKNOWN;
return ClusterStateEnum.UNKNOWN;
}

public Integer getState() {
return state;
}

public static boolean isRunning(ClusterState state) {
public static boolean isRunning(ClusterStateEnum state) {
return RUNNING.equals(state);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.streampark.common.enums;

public enum DevelopmentMode {
public enum DevelopmentModeEnum {

/** custom code */
CUSTOM_CODE("Custom Code", 1),
Expand All @@ -32,15 +32,15 @@ public enum DevelopmentMode {

private final Integer mode;

DevelopmentMode(String name, Integer mode) {
DevelopmentModeEnum(String name, Integer mode) {
this.name = name;
this.mode = mode;
}

public static DevelopmentMode of(Integer value) {
for (DevelopmentMode developmentMode : values()) {
if (developmentMode.mode.equals(value)) {
return developmentMode;
public static DevelopmentModeEnum of(Integer value) {
for (DevelopmentModeEnum developmentModeEnum : values()) {
if (developmentModeEnum.mode.equals(value)) {
return developmentModeEnum;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

import java.util.List;

public enum ExecutionMode {
public enum ExecutionModeEnum {

/** Local mode */
LOCAL(0, "local"),
Expand All @@ -48,24 +48,24 @@ public enum ExecutionMode {

private final String name;

ExecutionMode(Integer mode, String name) {
ExecutionModeEnum(Integer mode, String name) {
this.mode = mode;
this.name = name;
}

public static ExecutionMode of(Integer value) {
for (ExecutionMode executionMode : values()) {
if (executionMode.mode.equals(value)) {
return executionMode;
public static ExecutionModeEnum of(Integer value) {
for (ExecutionModeEnum executionModeEnum : values()) {
if (executionModeEnum.mode.equals(value)) {
return executionModeEnum;
}
}
return null;
}

public static ExecutionMode of(String name) {
for (ExecutionMode executionMode : values()) {
if (executionMode.name.equals(name)) {
return executionMode;
public static ExecutionModeEnum of(String name) {
for (ExecutionModeEnum executionModeEnum : values()) {
if (executionModeEnum.name.equals(name)) {
return executionModeEnum;
}
}
return null;
Expand All @@ -79,17 +79,17 @@ public String getName() {
return name;
}

public static boolean isYarnMode(ExecutionMode mode) {
public static boolean isYarnMode(ExecutionModeEnum 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.
public static boolean isYarnPerJobOrAppMode(ExecutionMode mode) {
public static boolean isYarnPerJobOrAppMode(ExecutionModeEnum mode) {
return YARN_PER_JOB == mode || YARN_APPLICATION == mode;
}

public static boolean isYarnSessionMode(ExecutionMode mode) {
public static boolean isYarnSessionMode(ExecutionModeEnum mode) {
return YARN_SESSION == mode;
}

Expand All @@ -101,7 +101,7 @@ public static boolean isKubernetesSessionMode(Integer value) {
return KUBERNETES_NATIVE_SESSION == of(value);
}

public static boolean isKubernetesMode(ExecutionMode mode) {
public static boolean isKubernetesMode(ExecutionModeEnum mode) {
return KUBERNETES_NATIVE_SESSION == mode || KUBERNETES_NATIVE_APPLICATION == mode;
}

Expand All @@ -118,15 +118,15 @@ public static List<Integer> getKubernetesMode() {
KUBERNETES_NATIVE_SESSION.getMode(), KUBERNETES_NATIVE_APPLICATION.getMode());
}

public static boolean isSessionMode(ExecutionMode mode) {
public static boolean isSessionMode(ExecutionModeEnum mode) {
return KUBERNETES_NATIVE_SESSION == mode || YARN_SESSION == mode;
}

public static boolean isRemoteMode(Integer value) {
return isRemoteMode(of(value));
}

public static boolean isRemoteMode(ExecutionMode mode) {
public static boolean isRemoteMode(ExecutionModeEnum mode) {
return REMOTE == mode;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.streampark.common.enums;

/** kubernetes.rest-service.exposed.type */
public enum FlinkK8sRestExposedType {
public enum FlinkK8sRestExposedTypeEnum {

/** LoadBalancer */
LOAD_BALANCER("LoadBalancer", 0),
Expand All @@ -33,13 +33,13 @@ public enum FlinkK8sRestExposedType {

private final Integer type;

FlinkK8sRestExposedType(String name, Integer type) {
FlinkK8sRestExposedTypeEnum(String name, Integer type) {
this.name = name;
this.type = type;
}

public static FlinkK8sRestExposedType of(Integer value) {
for (FlinkK8sRestExposedType order : values()) {
public static FlinkK8sRestExposedTypeEnum of(Integer value) {
for (FlinkK8sRestExposedTypeEnum order : values()) {
if (order.type.equals(value)) {
return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package org.apache.streampark.common.enums;

public enum FlinkSqlValidationFailedType {
public enum FlinkSqlValidationFailedTypeEnum {

/** Basic test failed (such as null, etc.) */
VERIFY_FAILED(1),
Expand All @@ -36,12 +36,12 @@ public enum FlinkSqlValidationFailedType {

private final int failedType;

FlinkSqlValidationFailedType(int failedType) {
FlinkSqlValidationFailedTypeEnum(int failedType) {
this.failedType = failedType;
}

public static FlinkSqlValidationFailedType of(Integer value) {
for (FlinkSqlValidationFailedType type : values()) {
public static FlinkSqlValidationFailedTypeEnum of(Integer value) {
for (FlinkSqlValidationFailedTypeEnum type : values()) {
if (type.failedType == value) {
return type;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.streampark.common.enums;

/** classloader.resolve-order */
public enum ResolveOrder {
public enum ResolveOrderEnum {

/** parent-first */
PARENT_FIRST("parent-first", 0),
Expand All @@ -30,13 +30,13 @@ public enum ResolveOrder {

private final Integer order;

ResolveOrder(String name, Integer order) {
ResolveOrderEnum(String name, Integer order) {
this.name = name;
this.order = order;
}

public static ResolveOrder of(Integer value) {
for (ResolveOrder order : values()) {
public static ResolveOrderEnum of(Integer value) {
for (ResolveOrderEnum order : values()) {
if (order.order.equals(value)) {
return order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import java.util.Objects;

public enum RestoreMode {
public enum RestoreModeEnum {

/**
* In this mode Flink claims ownership of the snapshot and essentially treats it like a
Expand Down Expand Up @@ -51,18 +51,18 @@ public int get() {
return this.mode;
}

RestoreMode(int mode) {
RestoreModeEnum(int mode) {
this.mode = mode;
}

public String getName() {
return this.toString();
}

public static RestoreMode of(Integer value) {
for (RestoreMode restoreMode : values()) {
if (Objects.equals(restoreMode.mode, value)) {
return restoreMode;
public static RestoreModeEnum of(Integer value) {
for (RestoreModeEnum restoreModeEnum : values()) {
if (Objects.equals(restoreModeEnum.mode, value)) {
return restoreModeEnum;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package org.apache.streampark.common.enums;

/** Flink consistency semantics */
public enum Semantic {
public enum SemanticEnum {

/**
* Ensure that the counting results obtained after a fault are consistent with the correct values.
Expand All @@ -31,10 +31,10 @@ public enum Semantic {
/** After the fault occurs, the counting results may be lost. */
NONE;

public static Semantic of(String name) {
for (Semantic semantic : Semantic.values()) {
if (name.equals(semantic.name())) {
return semantic;
public static SemanticEnum of(String name) {
for (SemanticEnum semanticEnum : SemanticEnum.values()) {
if (name.equals(semanticEnum.name())) {
return semanticEnum;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import org.apache.commons.lang3.StringUtils;

public enum StorageType {
public enum StorageTypeEnum {

/** hdfs */
HDFS("hdfs"),
Expand All @@ -29,19 +29,19 @@ public enum StorageType {

private final String type;

StorageType(String type) {
StorageTypeEnum(String type) {
this.type = type;
}

public String getType() {
return type;
}

public static StorageType of(String identifier) {
public static StorageTypeEnum of(String identifier) {
if (StringUtils.isBlank(identifier)) {
return LFS;
}
for (StorageType type : values()) {
for (StorageTypeEnum type : values()) {
if (type.type.equals(identifier)) {
return type;
}
Expand Down
Loading

0 comments on commit 2274d55

Please sign in to comment.