devutility.internal.test.data.constants.Gender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of devutility.internal Show documentation
Show all versions of devutility.internal Show documentation
Some utilities for Java development
package devutility.internal.test.data.constants;
import devutility.internal.annotations.Convertor;
/**
*
* Gender
*
* @author: Aldwin Su
*/
public enum Gender {
/**
* Unknow
*/
UNKNOW(0),
/**
* Mail
*/
MALE(1),
/**
* Femail
*/
FEMALE(2);
private int value;
private Gender(int value) {
this.value = value;
}
public int getValue() {
return value;
}
@Convertor
public static Gender parse(String value) {
Gender[] array = Gender.values();
for (int i = 0; i < array.length; i++) {
if (Integer.valueOf(value) == array[i].value) {
return array[i];
}
}
return Gender.UNKNOW;
}
public static Gender parse(int value) {
Gender[] array = Gender.values();
for (int i = 0; i < array.length; i++) {
if (value == array[i].value) {
return array[i];
}
}
return Gender.UNKNOW;
}
@Override
public String toString() {
return String.valueOf(value);
}
}