使用springboot 和lombok 注解开发
package com.wonders.disabled.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @since
* @author peng
* @date 2022/2/15 9:27
* @version
* @param
* @return
*/
@Getter
@AllArgsConstructor
public enum SexEnum {
MAN("1","男"),
WOMEN("0","女");
private final String code;
private final String desc;
public static SexEnum getEnum(String code){
for (SexEnum value : SexEnum.values()) {
if (code.equals(value.code)){
return value;
}
}
return null;
}
public static SexEnum getEnumByDesc(String desc){
for (SexEnum value : SexEnum.values()) {
if (desc.equals(value.desc)){
return value;
}
}
return null;
}
}