Object AddressFormUtils
-
- All Implemented Interfaces:
@RestrictTo(value = {RestrictTo.Scope.LIBRARY_GROUP}) public class AddressFormUtils
-
-
Field Summary
Fields Modifier and Type Field Description public final static AddressFormUtilsINSTANCE
-
Method Summary
Modifier and Type Method Description final List<AddressListItem>markAddressListItemSelected(List<AddressListItem> list, String code)Mark the item that matches the given code as selected in the given input list. final List<AddressListItem>initializeCountryOptions(Locale shopperLocale, AddressParams addressParams, List<AddressItem> countryList)Initialize country options using AddressParams. final List<AddressListItem>initializeStateOptions(List<AddressItem> stateList)Initialize state options. final BooleanisAddressRequired(AddressFormUIState addressFormUIState)Check whether the address is required for creation of Payment Component Data. final AddressmakeAddressData(AddressOutputData addressOutputData, AddressFormUIState addressFormUIState)Make Address object from the output data. final StringmakeHouseNumberOrName(String houseNumberOrName, String apartmentSuite)Make Address.houseNumberOrName field using houseNumberOrName and apartmentSuite fields. -
-
Method Detail
-
markAddressListItemSelected
final List<AddressListItem> markAddressListItemSelected(List<AddressListItem> list, String code)
Mark the item that matches the given code as selected in the given input list.
- Parameters:
list- Input list of AddressListItem.code- Country or state code to be marked as selected.- Returns:
List of AddressListItem with the item in the list having given code marked as selected.
-
initializeCountryOptions
final List<AddressListItem> initializeCountryOptions(Locale shopperLocale, AddressParams addressParams, List<AddressItem> countryList)
Initialize country options using AddressParams.
First filter if there's AddressParams.FullAddress.supportedCountryCodes defined in the configuration. Then mark AddressParams.FullAddress.defaultCountryCode as selected if it is defined in configuration and exists in the filtered country list. Otherwise mark first item in the list as selected.
- Parameters:
addressParams- object.countryList- List of countries from API.- Returns:
Country options.
-
initializeStateOptions
final List<AddressListItem> initializeStateOptions(List<AddressItem> stateList)
Initialize state options.
- Parameters:
stateList- List of states from API.- Returns:
State options.
-
isAddressRequired
final Boolean isAddressRequired(AddressFormUIState addressFormUIState)
Check whether the address is required for creation of Payment Component Data.
- Parameters:
addressFormUIState- UI state of the form.- Returns:
Whether if address data is required or not.
-
makeAddressData
final Address makeAddressData(AddressOutputData addressOutputData, AddressFormUIState addressFormUIState)
Make Address object from the output data.
- Parameters:
addressOutputData- Output data object storing the data from the form.addressFormUIState- UI state of the form.- Returns:
Address object to be passed to the merchant as part of Payment Component Data.
-
makeHouseNumberOrName
final String makeHouseNumberOrName(String houseNumberOrName, String apartmentSuite)
Make Address.houseNumberOrName field using houseNumberOrName and apartmentSuite fields.
Concat two fields and separate them with an empty space if both exists.
- Returns:
Resulting houseNumberOrName string.
-
-
-
-