@Override public String toString() { return (addressName == null) ? address.getFirstName() + " - " + address.getAddressLine1() : addressName; }
protected NameResponse getName(Address address) { NameResponse response = new NameResponse(); if (BLCSystemProperty.resolveBooleanSystemProperty("validator.address.fullNameOnly")) { String fullName = address.getFullName(); if (StringUtils.isNotBlank(fullName)) { char nameSeparatorChar = ' '; int spaceCharacterIndex = fullName.indexOf(nameSeparatorChar); if (spaceCharacterIndex != -1 && (fullName.length() > spaceCharacterIndex + 1)) { response.firstName = fullName.substring(0, spaceCharacterIndex); // use lastIndexOf instead of indexOf to deal with the case where a user put <first> <middle> <last> response.lastName = fullName.substring(fullName.lastIndexOf(nameSeparatorChar) + 1, fullName.length()); } else { response.firstName = fullName; response.lastName = ""; } } } else { response.firstName = address.getFirstName(); response.lastName = address.getLastName(); } return response; }
dest.setFirstName(orig.getFirstName()); dest.setLastName(orig.getLastName()); dest.setAddressLine1(orig.getAddressLine1());
private void validateCustomerDataInAddress(Address address) throws OrderValidationException { if(StringUtils.isEmpty(address.getFirstName()) || StringUtils.isEmpty(address.getLastName())) { throw new OrderValidationException("Provided address does not contain First and/or Last names"); } if(StringUtils.isEmpty(address.getAddressLine1())){ throw new OrderValidationException("Provided address does not contain address lines"); } if(StringUtils.isEmpty(address.getPostalCode()) || StringUtils.isEmpty(address.getCity())) { throw new OrderValidationException("Provided address does not contain postal code and/or city"); } if(address.getIsoCountryAlpha2() == null) { throw new OrderValidationException("Provided address does not contain valid country code"); } }
@Override public AddressDto createDto(final Address address, final boolean embed, final boolean link) { return AddressDto.builder() .addressLine1(address.getAddressLine1()) .addressLine2(address.getAddressLine2()) .addressLine3(address.getAddressLine3()) .firstName(address.getFirstName()) .lastName(address.getLastName()) .city(address.getCity()) .postalCode(address.getPostalCode()) .companyName(address.getCompanyName()) .countryCode(Optional.ofNullable(address.getIsoCountryAlpha2()).map(ISOCountry::getAlpha2).orElse(null)) .countrySubdivisionCode(address.getIsoCountrySubdivision()) .email(address.getEmailAddress()) .phone(Optional.ofNullable(address.getPhonePrimary()).map(phoneNumberFormat::format).orElse(null)) .build(); }