【代码评审】IoT:插件管理相关的逻辑
This commit is contained in:
@@ -13,7 +13,7 @@ import java.util.Arrays;
|
||||
@Getter
|
||||
public enum IotPluginDeployTypeEnum implements IntArrayValuable {
|
||||
|
||||
UPLOAD(0, "上传jar"),
|
||||
UPLOAD(0, "上传 jar"), // TODO @haohao:UPLOAD 和 ALONE 感觉有点冲突,前者是部署方式,后者是运行方式。这个后续再讨论下哈
|
||||
ALONE(1, "独立运行");
|
||||
|
||||
public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(IotPluginDeployTypeEnum::getDeployType).toArray();
|
||||
|
@@ -42,6 +42,11 @@ public enum IotPluginStatusEnum implements IntArrayValuable {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
public static boolean isValidState(Integer state) {
|
||||
return fromState(state) != null;
|
||||
}
|
||||
@@ -50,8 +55,4 @@ public enum IotPluginStatusEnum implements IntArrayValuable {
|
||||
return Arrays.stream(values()).anyMatch(e -> e.getStatus().equals(status));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return new int[0];
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.iot.enums.plugin;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.core.IntArrayValuable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
@@ -10,6 +11,7 @@ import java.util.Arrays;
|
||||
*
|
||||
* @author haohao
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum IotPluginTypeEnum implements IntArrayValuable {
|
||||
|
||||
@@ -28,11 +30,12 @@ public enum IotPluginTypeEnum implements IntArrayValuable {
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
IotPluginTypeEnum(Integer type, String name) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
|
||||
// TODO @haohao:可以使用 hutool 简化
|
||||
public static IotPluginTypeEnum fromType(Integer type) {
|
||||
for (IotPluginTypeEnum value : values()) {
|
||||
if (value.getType().equals(type)) {
|
||||
@@ -46,8 +49,4 @@ public enum IotPluginTypeEnum implements IntArrayValuable {
|
||||
return fromType(type) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] array() {
|
||||
return ARRAYS;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user