Repository for the HealthTool which enables Apple users to analyse their health data from the Apple health app and prepares the data for contributing it for future studies on wearable data.
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

3 years ago
  1. package application.enums;
  2. import application.res.*;
  3. public enum BloodType
  4. {
  5. A_POSITIVE("A+", "HKBloodTypeAPositive"),
  6. A_NEGATIVE("A-", "HKBloodTypeANegative"),
  7. B_POSITIVE("B+", "HKBloodTypeBPositive"),
  8. B_NEGATIVE("B-", "HKBloodTypeBNegative"),
  9. AB_POSITIVE("AB+", "HKBloodTypeABPositive"),
  10. AB_NEGATIVE("AB-", "HKBloodTypeABNegative"),
  11. O_POSITIVE("O+", "HKBloodTypeOPositive"),
  12. O_NEGATIVE("O-", "HKBloodTypeONegative"),
  13. NOT_SET(Text.NOT_SET,"HKBloodTypeNotSet"),
  14. NOT_PARSED("","");
  15. //Those two are used to match the found values with the enum
  16. /** A word which could be contained**/
  17. private final String shortTag;
  18. /** The exact value the attribute should have, but I don't know if they are correct **/
  19. private final String exactTag;
  20. BloodType(String shor, String exact)
  21. {
  22. this.shortTag=shor;
  23. this.exactTag=exact;
  24. }
  25. /**
  26. * Returns a short string which can be used to identify the value. Readable for users.
  27. * @return the respective String
  28. */
  29. public String getReadableValue()
  30. {
  31. return shortTag;
  32. }
  33. /**
  34. * For the input string returns the matching enum value
  35. * @param input String to compare
  36. * @return matched enum value
  37. */
  38. public static BloodType getValue(String input)
  39. {
  40. if(input.equalsIgnoreCase(A_POSITIVE.exactTag)|| input.contains(A_POSITIVE.shortTag))
  41. {
  42. return A_POSITIVE;
  43. }
  44. if(input.equalsIgnoreCase(A_NEGATIVE.exactTag)|| input.contains(A_NEGATIVE.shortTag))
  45. {
  46. return A_NEGATIVE;
  47. }
  48. if(input.equalsIgnoreCase(B_POSITIVE.exactTag)|| input.contains(B_POSITIVE.shortTag))
  49. {
  50. return B_POSITIVE;
  51. }
  52. if(input.equalsIgnoreCase(B_NEGATIVE.exactTag)|| input.contains(B_NEGATIVE.shortTag))
  53. {
  54. return B_NEGATIVE;
  55. }
  56. if(input.equalsIgnoreCase(AB_POSITIVE.exactTag)|| input.contains(AB_POSITIVE.shortTag))
  57. {
  58. return AB_POSITIVE;
  59. }
  60. if(input.equalsIgnoreCase(AB_NEGATIVE.exactTag)|| input.contains(AB_NEGATIVE.shortTag))
  61. {
  62. return AB_NEGATIVE;
  63. }
  64. if(input.equalsIgnoreCase(O_POSITIVE.exactTag)|| input.contains(O_POSITIVE.shortTag))
  65. {
  66. return O_POSITIVE;
  67. }
  68. if(input.equalsIgnoreCase(O_NEGATIVE.exactTag)|| input.contains(O_NEGATIVE.shortTag))
  69. {
  70. return O_NEGATIVE;
  71. }
  72. if(input.equalsIgnoreCase(NOT_SET.exactTag)|| input.contains(NOT_SET.shortTag))
  73. {
  74. return NOT_SET;
  75. }
  76. return NOT_PARSED;
  77. }
  78. }