How to Avoid Conditional Check Duplication In the code, I am checking altPhoneExist and altEmailExist conditions multiple times. How can I avoid this and improve the performance and readability of the code?
Code Description:
A contact is created and added to a list if one of the conditions is true. And a different set operation executed for each one.
boolean altPhoneExist = contact.getAlternativePhoneNumber() != null;
boolean altEmailExist = contact.getAlternativeEmail() != null;

if (altPhoneExist || altEmailExist) {

    if (altPhoneExist) {
        contact.setPhoneNumber(contact.getAlternativePhoneNumber());
    }

    if (altEmailExist) {
        contact.setEmail(contact.getAlternativeEmail());
    }

    rqType.getContactInfoList().add(CraneFactory.createContactPerson(contact));
}
In my opinion, there are not other good ways that I see to avoid this kind of logic; you can attenuate the arrow code by inverting the first condition and returning early.
if (!altPhoneExist &amp;&amp; !altEmailExist) {
   return;
}

// Here we know it's either one of them


if (altPhoneExist) {
   contact.setPhoneNumber(contact.getAlternativePhoneNumber());
}

if (altEmailExist) {
   contact.setEmail(contact.getAlternativeEmail());
}

rqType.getContactInfoList().add(CraneFactory.createContactPerson(contact));