Package org.cyclos.impl.utils
Interface PhoneNumberHandler
-
public interface PhoneNumberHandlerHandles phone numbers
-
-
Field Summary
Fields Modifier and Type Field Description static StringATTR_COUNTRYScript attribute: The country codestatic StringATTR_LAND_LINEScript attribute: The example should be of a fixed land-linestatic StringATTR_MOBILEScript attribute: The example should be of a mobilestatic StringATTR_NUMBERScript attribute: The input phone number
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default booleanequals(PhoneNumberDescriptor d1, PhoneNumberDescriptor d2)Indicates whether both descriptors represent the same normalized numberdefault Stringformat(PhoneNumberDescriptor number, ConfigurationAccessor configuration)Formats the number with the given conditions: IfConfigurationAccessor.isAlwaysShowInternationalPhoneNumber(), callsPhoneNumberDescriptor.toInternationalFormat().intgetCountryCode(String country)Returns the dialing code for the given country codeStringgetExampleNumber(PhoneNature nature, ConfigurationAccessor configuration)Returns a phone number which serves as example for the given phone type, for a given configuration.default booleanisValid(String rawNumber, ConfigurationAccessor configuration, PhoneNature expectedNature)Validates whether the given phone number is valid for the given configuration default country.PhoneNumberDescriptorparse(String rawNumber, ConfigurationAccessor configuration)Parses the given number, according to the given configuration.PhoneNumberDescriptortoDescriptor(Phone phone)Converts the givenPhoneto aPhoneNumberDescriptor, returning null in case of failures.default StringtryNormalize(String rawNumber, ConfigurationAccessor configuration)Attempts to normalize the given number, by parsing.
-
-
-
Field Detail
-
ATTR_COUNTRY
static final String ATTR_COUNTRY
Script attribute: The country code- See Also:
- Constant Field Values
-
ATTR_MOBILE
static final String ATTR_MOBILE
Script attribute: The example should be of a mobile- See Also:
- Constant Field Values
-
ATTR_LAND_LINE
static final String ATTR_LAND_LINE
Script attribute: The example should be of a fixed land-line- See Also:
- Constant Field Values
-
ATTR_NUMBER
static final String ATTR_NUMBER
Script attribute: The input phone number- See Also:
- Constant Field Values
-
-
Method Detail
-
equals
default boolean equals(PhoneNumberDescriptor d1, PhoneNumberDescriptor d2)
Indicates whether both descriptors represent the same normalized number
-
format
default String format(PhoneNumberDescriptor number, ConfigurationAccessor configuration)
Formats the number with the given conditions: IfConfigurationAccessor.isAlwaysShowInternationalPhoneNumber(), callsPhoneNumberDescriptor.toInternationalFormat(). Otherwise, checks for the country code of the number and the default one from the configuration. If they are the same, callsPhoneNumberDescriptor.toNationalFormat(), otherwise,PhoneNumberDescriptor.toInternationalFormat().
-
getCountryCode
int getCountryCode(String country)
Returns the dialing code for the given country code
-
getExampleNumber
String getExampleNumber(PhoneNature nature, ConfigurationAccessor configuration)
Returns a phone number which serves as example for the given phone type, for a given configuration. The result is formatted as national.
-
isValid
default boolean isValid(String rawNumber, ConfigurationAccessor configuration, PhoneNature expectedNature)
Validates whether the given phone number is valid for the given configuration default country. When an expected nature is passed, the phone needs to match it.
-
parse
@Nullable PhoneNumberDescriptor parse(@Nullable String rawNumber, ConfigurationAccessor configuration)
Parses the given number, according to the given configuration. Returns null on null or invalid input.
-
toDescriptor
@Nullable PhoneNumberDescriptor toDescriptor(@Nullable Phone phone)
Converts the givenPhoneto aPhoneNumberDescriptor, returning null in case of failures.
-
tryNormalize
default String tryNormalize(@Nullable String rawNumber, ConfigurationAccessor configuration)
Attempts to normalize the given number, by parsing. If succeed, returns the E164 format, otherwise, returns the input as is.
-
-