private String returnHigherPrecendenceString(String value1, String value2) { if (value1.equals(value2)) { return value1; } else if (oneStringEmpty(value1, value2)) { return returnNonEmptyString(value1, value2); } else if (vitalStatusChanged(value1, value2)) { if (VitalStatusAlive.has(value1) && VitalStatusDead.has(value2)) return VitalStatusDead.DEAD.toString(); // alive - dead --> dead if (VitalStatusDead.has(value1) && VitalStatusAlive.has(value2)) return VitalStatusDead.DEAD.toString(); // dead - alive --> dead if (VitalStatusAlive.has(value1) && !VitalStatusDead.has(value2)) return VitalStatusAlive.ALIVE.toString(); // alive - [Not Available] --> alive if (VitalStatusDead.has(value1) && !VitalStatusAlive.has(value2)) return VitalStatusDead.DEAD.toString(); // dead - [Not Available] --> dead if (!VitalStatusAlive.has(value1) && VitalStatusAlive.has(value2)) return VitalStatusAlive.ALIVE.toString(); // [Not Available] - alive --> alive if (!VitalStatusAlive.has(value1) && VitalStatusDead.has(value2)) return VitalStatusDead.DEAD.toString(); // [Not Available] - deade --> dead return VitalStatusDead.DEAD.toString(); } else if (missingAttributeChanged(value1, value2)) { return returnHigherPrecedenceMissingAttribute(value1, value2); } assert true == false : String.format("returnHigherPrecendenceString, %s, %s", value1, value2); return MissingAttributeValues.MISSING.toString(); }
// assumes value1 and value2 are Missing attributes and not equal private String returnHigherPrecedenceMissingAttribute(String value1, String value2) { if (value1.equals(MissingAttributeValues.NULL.toString()) && MissingAttributeValues.has(value2) && !value2.equals(MissingAttributeValues.NULL.toString())) { return value1; } else if (value2.equals(MissingAttributeValues.NULL.toString()) && MissingAttributeValues.has(value1) && !value1.equals(MissingAttributeValues.NULL.toString())) { return value2; } assert true == false : String.format("returnHigherPrecendenceMissingAttribute, %s, %s", value1, value2); return MissingAttributeValues.MISSING.toString(); }