package com.ywt.alipaympapi.models.enums;


public enum SexEnum {
    Unknown("未知", 0),
    Male("男", 1),
    Female("女", 2),
    Unspecified("未说明", 9);

    private final String displayName;

    private int value = 0;

    SexEnum(String displayName, int value) {
        this.displayName = displayName;
        this.value = value;
    }

    public String getDisplayName() {
        return displayName;
    }

    public int getValue() {
        return value;
    }

    public static SexEnum valueOf(int value) {
        for(SexEnum sexEnum : SexEnum.values()){
            if(sexEnum.getValue() == value){
                return sexEnum;
            }
        }
        return null;
    }

    public static SexEnum getSexByName(String value){
        for(SexEnum sexEnum : SexEnum.values()){
            if(value.equals(sexEnum.getDisplayName())){
                return sexEnum;
            }
        }
        return Unknown;
    }

    public static String getSexDisplayName(int value){
        SexEnum sexEnum = valueOf(value);

        if(sexEnum != null){
            return sexEnum.getDisplayName();
        }

        return "未知";
    }


}