Gender 放到 constant 包中

dev
ZhouXY108 2024-11-28 16:36:01 +08:00
parent fba195afc7
commit 96f7eac10a
4 changed files with 15 additions and 2 deletions

View File

@ -14,8 +14,9 @@
* limitations under the License. * limitations under the License.
*/ */
package xyz.zhouxy.plusone.commons.model; package xyz.zhouxy.plusone.commons.constant;
import xyz.zhouxy.plusone.commons.base.IWithIntCode;
import xyz.zhouxy.plusone.commons.util.AssertTools; import xyz.zhouxy.plusone.commons.util.AssertTools;
/** /**
@ -23,7 +24,7 @@ import xyz.zhouxy.plusone.commons.util.AssertTools;
* *
* @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a> * @author <a href="http://zhouxy.xyz:3000/ZhouXY108">ZhouXY</a>
*/ */
public enum Gender { public enum Gender implements IWithIntCode {
UNKNOWN(0, "Unknown", "未知"), UNKNOWN(0, "Unknown", "未知"),
MALE(1, "Male", "男"), MALE(1, "Male", "男"),
FEMALE(2, "Female", "女"), FEMALE(2, "Female", "女"),
@ -52,6 +53,11 @@ public enum Gender {
return value; return value;
} }
@Override
public int getCode() {
return value;
}
public String getDisplayName() { public String getDisplayName() {
return displayName; return displayName;
} }

View File

@ -25,10 +25,14 @@ import java.util.regex.Pattern;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.Immutable;
import xyz.zhouxy.plusone.commons.constant.Gender;
/** /**
* *
*/ */
@Immutable
public class Chinese2ndGenIDCardNumber extends IDCardNumber { public class Chinese2ndGenIDCardNumber extends IDCardNumber {
/** 省份编码 */ /** 省份编码 */

View File

@ -23,6 +23,8 @@ import java.util.regex.Pattern;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import xyz.zhouxy.plusone.commons.constant.Gender;
/** /**
* *
*/ */

View File

@ -26,6 +26,7 @@ import java.util.regex.Matcher;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import xyz.zhouxy.plusone.commons.constant.Gender;
@Slf4j @Slf4j
public class Chinese2ndGenIDCardNumberTests { public class Chinese2ndGenIDCardNumberTests {