/** * Gets a valid short number for the specified cost category. * * @param regionCode the region for which an example short number is needed * @param cost the cost category of number that is needed * @return a valid short number for the specified region and cost category. Returns an empty * string when the metadata does not contain such information, or the cost is UNKNOWN_COST. */ // @VisibleForTesting internal String getExampleShortNumberForCost(String regionCode, ShortNumberCost cost) { PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode); if (phoneMetadata == null) { return(""); } PhoneNumberDesc desc = null; switch (cost) { case ShortNumberCost.TOLL_FREE: desc = phoneMetadata.getTollFree(); break; case ShortNumberCost.STANDARD_RATE: desc = phoneMetadata.getStandardRate(); break; case ShortNumberCost.PREMIUM_RATE: desc = phoneMetadata.getPremiumRate(); break; default: // UNKNOWN_COST numbers are computed by the process of elimination from the other cost // categories. break; } if (desc != null && desc.HasExampleNumber()) { return(desc.getExampleNumber()); } return(""); }
public PhoneNumberDesc mergeFrom(PhoneNumberDesc other) { if (other.HasNationalNumberPattern()) { setNationalNumberPattern(other.getNationalNumberPattern()); } if (other.HasPossibleNumberPattern()) { setPossibleNumberPattern(other.getPossibleNumberPattern()); } if (other.HasExampleNumber()) { setExampleNumber(other.getExampleNumber()); } return(this); }
/** * Gets a valid short number for the specified region. * * @param regionCode the region for which an example short number is needed * @return a valid short number for the specified region. Returns an empty string when the * metadata does not contain such information. */ // @VisibleForTesting internal String getExampleShortNumber(String regionCode) { PhoneMetadata phoneMetadata = MetadataManager.getShortNumberMetadataForRegion(regionCode); if (phoneMetadata == null) { return(""); } PhoneNumberDesc desc = phoneMetadata.getShortCode(); if (desc.HasExampleNumber()) { return(desc.getExampleNumber()); } return(""); }