package application.enums; import application.res.*; public enum BiologicalSex { MALE("male", "HKBiologicalSexMale"), FEMALE("female","HKBiologicalSexFemale"), OTHER("other","HKBiologicalSexOther"), NOT_SET(Text.NOT_SET,"HKBiologicalSexNotSet"), 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; BiologicalSex(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 BiologicalSex getValue(String input) { if(input.equalsIgnoreCase(FEMALE.exactTag)|| input.contains(FEMALE.shortTag)) { return FEMALE; } if(input.equalsIgnoreCase(MALE.exactTag)|| input.contains(MALE.shortTag)) { return MALE; } if(input.equalsIgnoreCase(OTHER.exactTag)|| input.contains(OTHER.shortTag)) { return OTHER; } if(input.equalsIgnoreCase(NOT_SET.exactTag)|| input.contains(NOT_SET.shortTag)) { return NOT_SET; } return NOT_PARSED; } }