public enum EnumConstType implements EntityQuery<EnumConstService, EnumConst> {
NEED("1"),
NOT_NEED("0");
public static final String NAMESPACE = "FlagVerifyType";
private String code;
EnumConstType(String code) {
this.code = code;
}
public String getCode() {
return code;
}
@Override
public EnumConst getBy(EnumConstService enumConstService) {
return enumConstService.getByNamespaceAndCode(NAMESPACE, this.code);
}
public static EnumConstType getByCode(String code) {
for (EnumConstType verifyType : values()) {
if (verifyType.getCode().equals(code)) {
return verifyType;
}
}
return null;
}
}
其中,,,,,,,,,,,,,,,,,
public static EnumConstType getByCode(String code) {
for (EnumConstType verifyType : values()) {
if (verifyType.getCode().equals(code)) {
return verifyType;
}
}
return null;
}
这段代码是一个静态方法,名为 getByCode
。它接受一个字符串参数 code
,并返回一个 EnumConstType
枚举类型的值。 该方法通过遍历 EnumConstType
枚举的所有值,比较每个枚举值的 code
属性与传入的参数 code
是否相等。如果找到匹配的枚举值,则返回该枚举值;否则返回 null
。 换句话说,这段代码的作用是根据传入的 code
值来获取对应的 EnumConstType
枚举值。