refactor(sj_1.1.0-beta3): enum 统一使用lombok

This commit is contained in:
dhb52 2024-07-10 23:18:11 +08:00
parent a202e23b09
commit e05b291556
15 changed files with 49 additions and 123 deletions

View File

@ -1,11 +1,16 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 预警类型
*
* @author: opensnail
* @date : 2021-11-25 09:19
*/
@AllArgsConstructor
@Getter
public enum AlarmTypeEnum {
/**
@ -36,11 +41,4 @@ public enum AlarmTypeEnum {
private final int value;
AlarmTypeEnum(int value) {
this.value = value;
}
public int getValue() {
return value;
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Objects;
@ -10,6 +11,7 @@ import java.util.Objects;
* @since 2.6.0
*/
@Getter
@AllArgsConstructor
public enum FailStrategyEnum {
SKIP(1, "跳过"),
@ -18,19 +20,6 @@ public enum FailStrategyEnum {
private final Integer code;
private final String desc;
FailStrategyEnum(Integer code, String desc) {
this.code = code;
this.desc = desc;
}
public Integer getCode() {
return code;
}
public String getDesc() {
return desc;
}
public static FailStrategyEnum valueOf(Integer code) {
for (FailStrategyEnum failStrategyEnum : FailStrategyEnum.values()) {
if (Objects.equals(failStrategyEnum.code, code)) {

View File

@ -1,11 +1,13 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author: opensnail
* @date : 2022-03-11 19:44
*/
@AllArgsConstructor
@Getter
public enum HeadersEnum {
@ -23,7 +25,4 @@ public enum HeadersEnum {
private final String key;
HeadersEnum(String key) {
this.key = key;
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -8,6 +9,7 @@ import lombok.Getter;
* @author: zuoJunLin
* @date : 2023-12-02 18:18
*/
@AllArgsConstructor
@Getter
public enum JobNotifySceneEnum {
@ -23,21 +25,15 @@ public enum JobNotifySceneEnum {
*/
private final int notifyScene;
/**
* 触发通知节点类型
*/
private final NodeTypeEnum nodeType;
/**
* 描述
*/
private final String desc;
JobNotifySceneEnum(int notifyScene, String desc, NodeTypeEnum nodeType) {
this.notifyScene = notifyScene;
this.desc = desc;
this.nodeType = nodeType;
}
/**
* 触发通知节点类型
*/
private final NodeTypeEnum nodeType;
/**
* 获取通知场景

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -8,6 +9,7 @@ import lombok.Getter;
* @author: opensnail
* @date : 2021-11-26 18:01
*/
@AllArgsConstructor
@Getter
public enum NodeTypeEnum {
@ -24,8 +26,4 @@ public enum NodeTypeEnum {
private final Integer type;
NodeTypeEnum(int type) {
this.type = type;
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -9,6 +10,7 @@ import lombok.Getter;
* @date : 2021-11-24 18:18
* @since : 1.0.0
*/
@AllArgsConstructor
@Getter
public enum RetryNotifySceneEnum {
@ -30,21 +32,15 @@ public enum RetryNotifySceneEnum {
*/
private final int notifyScene;
/**
* 触发通知节点类型
*/
private final NodeTypeEnum nodeType;
/**
* 描述
*/
private final String desc;
RetryNotifySceneEnum(int notifyScene, String desc, NodeTypeEnum nodeType) {
this.notifyScene = notifyScene;
this.desc = desc;
this.nodeType = nodeType;
}
/**
* 触发通知节点类型
*/
private final NodeTypeEnum nodeType;
/**
* 获取通知场景
@ -63,5 +59,4 @@ public enum RetryNotifySceneEnum {
return null;
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -8,6 +9,7 @@ import lombok.Getter;
* @author: opensnail
* @date : 2021-11-03 11:05
*/
@AllArgsConstructor
@Getter
public enum RetryResultStatusEnum {
@ -17,10 +19,6 @@ public enum RetryResultStatusEnum {
private final Integer status;
RetryResultStatusEnum(int status) {
this.status = status;
}
public static RetryResultStatusEnum getRetryResultStatusEnum(int status) {
for (RetryResultStatusEnum value : RetryResultStatusEnum.values()) {
if (value.status == status) {

View File

@ -45,13 +45,11 @@ public enum RetryStatusEnum {
}
public static RetryStatusEnum getByStatus(@NonNull Integer status) {
for (RetryStatusEnum value : RetryStatusEnum.values()) {
if (Objects.equals(value.status, status)) {
return value;
}
}
return null;
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -8,6 +9,7 @@ import lombok.Getter;
* @author: opensnail
* @date : 2021-11-26 17:58
*/
@AllArgsConstructor
@Getter
public enum StatusEnum {
@ -16,9 +18,4 @@ public enum StatusEnum {
private final Integer status;
StatusEnum(int status) {
this.status = status;
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.common.core.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -9,6 +10,7 @@ import lombok.Getter;
* @date 2023-12-24 08:13:43
* @since 2.6.0
*/
@AllArgsConstructor
@Getter
public enum WorkflowNodeTypeEnum {
JOB_TASK(1, "JOB任务"),
@ -19,19 +21,6 @@ public enum WorkflowNodeTypeEnum {
private final int type;
private final String desc;
WorkflowNodeTypeEnum(int type, String desc) {
this.type = type;
this.desc = desc;
}
public int getType() {
return type;
}
public String getDesc() {
return desc;
}
public static WorkflowNodeTypeEnum valueOf(int type) {
for (WorkflowNodeTypeEnum workflowNodeTypeEnum : WorkflowNodeTypeEnum.values()) {
if (workflowNodeTypeEnum.getType() == type) {

View File

@ -2,6 +2,7 @@ package com.aizuda.snailjob.server.common.allocate.client;
import com.aizuda.snailjob.server.common.ClientLoadBalance;
import com.aizuda.snailjob.server.common.exception.SnailJobServerException;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
@ -21,6 +22,7 @@ public class ClientLoadBalanceManager {
throw new SnailJobServerException("routeType is not existed. routeType:[{}]", routeType);
}
@AllArgsConstructor
@Getter
public enum AllocationAlgorithmEnum {
@ -32,10 +34,6 @@ public class ClientLoadBalanceManager {
private final int type;
private final ClientLoadBalance clientLoadBalance;
AllocationAlgorithmEnum(int type, ClientLoadBalance clientLoadBalance) {
this.type = type;
this.clientLoadBalance = clientLoadBalance;
}
}
}

View File

@ -1,5 +1,6 @@
package com.aizuda.snailjob.server.common.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.temporal.ChronoUnit;
@ -10,6 +11,7 @@ import java.time.temporal.ChronoUnit;
* @author: opensnail
* @date : 2021-11-29 17:30
*/
@AllArgsConstructor
@Getter
public enum DelayLevelEnum {
@ -41,27 +43,22 @@ public enum DelayLevelEnum {
_26(26, 12, ChronoUnit.HOURS),
;
/**
* 时间
*/
private final int time;
/**
* 等级
*/
private final int level;
/**
* 时间
*/
private final int time;
/**
* 单位
*/
private final ChronoUnit unit;
DelayLevelEnum(int level, int time, ChronoUnit unit) {
this.time = time;
this.unit = unit;
this.level = level;
}
/**
* 根据等级获取延迟等级枚举
*

View File

@ -7,6 +7,7 @@ import com.aizuda.snailjob.server.common.enums.DelayLevelEnum;
import com.aizuda.snailjob.server.common.exception.SnailJobServerException;
import com.aizuda.snailjob.server.common.util.DateUtils;
import com.google.common.base.Preconditions;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
@ -57,6 +58,7 @@ public class WaitStrategies {
}
}
@AllArgsConstructor
@Getter
public enum WaitStrategyEnum {
DELAY_LEVEL(1, delayLevelWait()),
@ -67,11 +69,6 @@ public class WaitStrategies {
private final int type;
private final WaitStrategy waitStrategy;
WaitStrategyEnum(int type, WaitStrategy waitStrategy) {
this.type = type;
this.waitStrategy = waitStrategy;
}
/**
* 获取退避策略
*

View File

@ -1,5 +1,8 @@
package com.aizuda.snailjob.server.web.annotation;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.HashMap;
import java.util.Map;
@ -7,6 +10,8 @@ import java.util.Map;
* @author: byteblogs
* @date: 2019/09/02 16:35
*/
@AllArgsConstructor
@Getter
public enum RoleEnum {
/**
@ -31,11 +36,6 @@ public enum RoleEnum {
private final String roleName;
RoleEnum(Integer roleId, String roleName) {
this.roleId = roleId;
this.roleName = roleName;
}
public static Map<Integer, RoleEnum> getEnumTypeMap() {
return enumTypeMap;
}
@ -48,12 +48,4 @@ public enum RoleEnum {
return USER.getRoleId().equals(roleId);
}
public Integer getRoleId() {
return roleId;
}
public String getRoleName() {
return roleName;
}
}

View File

@ -3,6 +3,8 @@ package com.aizuda.snailjob.server.web.model.enums;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.aizuda.snailjob.common.core.util.StreamUtils;
import com.aizuda.snailjob.server.web.model.response.DashboardLineResponseVO;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -17,6 +19,8 @@ import java.util.function.Function;
* @author: byteblogs
* @date: 2020/1/19 20:36
*/
@AllArgsConstructor
@Getter
public enum DateTypeEnum {
/**
* 按小时
@ -105,14 +109,6 @@ public enum DateTypeEnum {
private Function<LocalDateTime, LocalDateTime> startTime;
private Function<LocalDateTime, LocalDateTime> endTime;
DateTypeEnum(Consumer<List<DashboardLineResponseVO>> consumer,
Function<LocalDateTime, LocalDateTime> startTime,
Function<LocalDateTime, LocalDateTime> endTime) {
this.consumer = consumer;
this.startTime = startTime;
this.endTime = endTime;
}
private static DashboardLineResponseVO buildZeroedVoWithCreateDt(String createDt) {
return new DashboardLineResponseVO()
.setTotal(0L)
@ -129,15 +125,4 @@ public enum DateTypeEnum {
.setCreateDt(createDt);
}
public Function<LocalDateTime, LocalDateTime> getStartTime() {
return startTime;
}
public Function<LocalDateTime, LocalDateTime> getEndTime() {
return endTime;
}
public Consumer<List<DashboardLineResponseVO>> getConsumer() {
return consumer;
}
}