All Downloads are FREE. Search and download functionalities are using the official Maven repository.

travel.wink.wise.partner.credentials.api.WiseProfileComparator Maven / Gradle / Ivy

The newest version!
package travel.wink.wise.partner.credentials.api;

import travel.wink.wise.partner.customer.api.Customer;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

/**
 * The type Wise profile comparator.
 */
public class WiseProfileComparator {

    /**
     * Is tw profile equal to customer boolean.
     *
     * @param twProfile the tw profile
     * @param customer  the customer
     * @return the boolean
     */
    public static Boolean isTwProfileEqualToCustomer(final WiseProfile twProfile, final Customer customer) {
        ProfileDetails profileDetails = twProfile.getProfileDetails();

        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");

        if (profileDetails.getFirstName() != null ? !profileDetails.getFirstName().equals(customer.getFirstName()) : customer.getFirstName() != null) {
            return false;
        }
        if (profileDetails.getLastName() != null ? !profileDetails.getLastName().equals(customer.getLastName()) : customer.getLastName() != null) {
            return false;
        }
        if (profileDetails.getDateOfBirth() != null ? !LocalDate.parse(profileDetails.getDateOfBirth(), formatter).equals(customer.getDateOfBirth()) : customer.getDateOfBirth() != null) {
            return false;
        }
        if (profileDetails.getPhoneNumber() != null ? !profileDetails.getPhoneNumber().equals(customer.getPhoneNumber()) : customer.getPhoneNumber() == null) {
            return false;
        }

        return true;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy