You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
2.3 KiB
84 lines
2.3 KiB
package application.enums;
|
|
|
|
import application.res.*;
|
|
public enum BloodType
|
|
{
|
|
A_POSITIVE("A+", "HKBloodTypeAPositive"),
|
|
A_NEGATIVE("A-", "HKBloodTypeANegative"),
|
|
B_POSITIVE("B+", "HKBloodTypeBPositive"),
|
|
B_NEGATIVE("B-", "HKBloodTypeBNegative"),
|
|
AB_POSITIVE("AB+", "HKBloodTypeABPositive"),
|
|
AB_NEGATIVE("AB-", "HKBloodTypeABNegative"),
|
|
O_POSITIVE("O+", "HKBloodTypeOPositive"),
|
|
O_NEGATIVE("O-", "HKBloodTypeONegative"),
|
|
NOT_SET(Text.NOT_SET,"HKBloodTypeNotSet"),
|
|
NOT_PARSED("","");
|
|
|
|
//Those two are used to match the found values with the enum
|
|
/** A word which could be contained**/
|
|
private final String shortTag;
|
|
/** The exact value the attribute should have, but I don't know if they are correct **/
|
|
private final String exactTag;
|
|
|
|
BloodType(String shor, String exact)
|
|
{
|
|
this.shortTag=shor;
|
|
this.exactTag=exact;
|
|
}
|
|
|
|
|
|
/**
|
|
* Returns a short string which can be used to identify the value. Readable for users.
|
|
* @return the respective String
|
|
*/
|
|
public String getReadableValue()
|
|
{
|
|
return shortTag;
|
|
}
|
|
|
|
/**
|
|
* For the input string returns the matching enum value
|
|
* @param input String to compare
|
|
* @return matched enum value
|
|
*/
|
|
public static BloodType getValue(String input)
|
|
{
|
|
if(input.equalsIgnoreCase(A_POSITIVE.exactTag)|| input.contains(A_POSITIVE.shortTag))
|
|
{
|
|
return A_POSITIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(A_NEGATIVE.exactTag)|| input.contains(A_NEGATIVE.shortTag))
|
|
{
|
|
return A_NEGATIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(B_POSITIVE.exactTag)|| input.contains(B_POSITIVE.shortTag))
|
|
{
|
|
return B_POSITIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(B_NEGATIVE.exactTag)|| input.contains(B_NEGATIVE.shortTag))
|
|
{
|
|
return B_NEGATIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(AB_POSITIVE.exactTag)|| input.contains(AB_POSITIVE.shortTag))
|
|
{
|
|
return AB_POSITIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(AB_NEGATIVE.exactTag)|| input.contains(AB_NEGATIVE.shortTag))
|
|
{
|
|
return AB_NEGATIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(O_POSITIVE.exactTag)|| input.contains(O_POSITIVE.shortTag))
|
|
{
|
|
return O_POSITIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(O_NEGATIVE.exactTag)|| input.contains(O_NEGATIVE.shortTag))
|
|
{
|
|
return O_NEGATIVE;
|
|
}
|
|
if(input.equalsIgnoreCase(NOT_SET.exactTag)|| input.contains(NOT_SET.shortTag))
|
|
{
|
|
return NOT_SET;
|
|
}
|
|
return NOT_PARSED;
|
|
}
|
|
}
|