From c4a156c176cdcf0bccf43e7a0ce5ab2f8ecbfa88 Mon Sep 17 00:00:00 2001 From: karoljk Date: Wed, 18 Sep 2024 12:16:24 +0000 Subject: [PATCH 1/8] Rename NonGeographicalRegion to NonGeographicalEntity. This is to be consistent with the naming of non-geographical entities, since region and non-geographical can be contradictory. --- .../i18n/phonenumbers/AsYouTypeFormatter.java | 2 +- .../i18n/phonenumbers/PhoneNumberUtil.java | 28 +++++++---- .../source/FormattingMetadataSource.java | 2 +- .../metadata/source/MetadataSource.java | 2 +- .../metadata/source/MetadataSourceImpl.java | 9 ++++ .../NonGeographicalEntityMetadataSource.java | 25 ++-------- ...NonGeographicalEntityMetadataSourceV2.java | 47 +++++++++++++++++++ .../phonenumbers/PhoneNumberUtilTest.java | 12 ++--- 8 files changed, 88 insertions(+), 39 deletions(-) create mode 100644 java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSourceV2.java diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java index be11be57e..0d848227d 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/AsYouTypeFormatter.java @@ -612,7 +612,7 @@ public class AsYouTypeFormatter { nationalNumber.append(numberWithoutCountryCallingCode); String newRegionCode = phoneUtil.getRegionCodeForCountryCode(countryCode); if (PhoneNumberUtil.REGION_CODE_FOR_NON_GEO_ENTITY.equals(newRegionCode)) { - currentMetadata = phoneUtil.getMetadataForNonGeographicalRegion(countryCode); + currentMetadata = phoneUtil.getMetadataForNonGeographicalEntity(countryCode); } else if (!newRegionCode.equals(defaultCountry)) { currentMetadata = getMetadataForRegion(newRegionCode); } diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index e85cb65b5..4d2084adf 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -699,7 +699,7 @@ public class PhoneNumberUtil { // The set of country calling codes that map to the non-geo entity region ("001"). This set // currently contains < 12 elements so the default capacity of 16 (load factor=0.75) is fine. - private final Set countryCodesForNonGeographicalRegion = new HashSet<>(); + private final Set countryCodesForNonGeographicalEntity = new HashSet<>(); /** * This class implements a singleton, the constructor is only visible to facilitate testing. @@ -715,7 +715,7 @@ public class PhoneNumberUtil { // that's the only region code it maps to. if (regionCodes.size() == 1 && REGION_CODE_FOR_NON_GEO_ENTITY.equals(regionCodes.get(0))) { // This is the subset of all country codes that map to the non-geo entity region code. - countryCodesForNonGeographicalRegion.add(entry.getKey()); + countryCodesForNonGeographicalEntity.add(entry.getKey()); } else { // The supported regions set does not include the "001" non-geo entity region code. supportedRegions.addAll(regionCodes); @@ -1072,7 +1072,7 @@ public class PhoneNumberUtil { * library supports */ public Set getSupportedGlobalNetworkCallingCodes() { - return Collections.unmodifiableSet(countryCodesForNonGeographicalRegion); + return Collections.unmodifiableSet(countryCodesForNonGeographicalEntity); } /** @@ -1159,7 +1159,7 @@ public class PhoneNumberUtil { * entity. */ public Set getSupportedTypesForNonGeoEntity(int countryCallingCode) { - PhoneMetadata metadata = getMetadataForNonGeographicalRegion(countryCallingCode); + PhoneMetadata metadata = getMetadataForNonGeographicalEntity(countryCallingCode); if (metadata == null) { logger.log(Level.WARNING, "Unknown country calling code for a non-geographical entity " + "provided: " + countryCallingCode); @@ -1436,7 +1436,7 @@ public class PhoneNumberUtil { private PhoneMetadata getMetadataForRegionOrCallingCode( int countryCallingCode, String regionCode) { return REGION_CODE_FOR_NON_GEO_ENTITY.equals(regionCode) - ? getMetadataForNonGeographicalRegion(countryCallingCode) + ? getMetadataForNonGeographicalEntity(countryCallingCode) : getMetadataForRegion(regionCode); } @@ -2149,7 +2149,7 @@ public class PhoneNumberUtil { // If there wasn't an example number for a region, try the non-geographical entities. for (int countryCallingCode : getSupportedGlobalNetworkCallingCodes()) { PhoneNumberDesc desc = getNumberDescByType( - getMetadataForNonGeographicalRegion(countryCallingCode), type); + getMetadataForNonGeographicalEntity(countryCallingCode), type); try { if (desc.hasExampleNumber()) { return parse("+" + countryCallingCode + desc.getExampleNumber(), UNKNOWN_REGION); @@ -2171,7 +2171,7 @@ public class PhoneNumberUtil { * to a non-geographical entity. */ public PhoneNumber getExampleNumberForNonGeoEntity(int countryCallingCode) { - PhoneMetadata metadata = getMetadataForNonGeographicalRegion(countryCallingCode); + PhoneMetadata metadata = getMetadataForNonGeographicalEntity(countryCallingCode); if (metadata != null) { // For geographical entities, fixed-line data is always present. However, for non-geographical // entities, this is not the case, so we have to go through different types to find the @@ -2322,6 +2322,14 @@ public class PhoneNumberUtil { return phoneMetadata; } + /** + * @deprecated use the following name {@link #getMetadataForNonGeographicalEntity} + */ + @Deprecated + PhoneMetadata getMetadataForNonGeographicalRegion(int countryCallingCode) { + return getMetadataForNonGeographicalEntity(countryCallingCode); + } + /** * Returns the metadata for the given country calling code or {@code null} if the country calling * code is invalid or unknown. @@ -2329,11 +2337,11 @@ public class PhoneNumberUtil { * @throws MissingMetadataException if the country calling code is valid, but metadata cannot be * found. */ - PhoneMetadata getMetadataForNonGeographicalRegion(int countryCallingCode) { - if (!countryCodesForNonGeographicalRegion.contains(countryCallingCode)) { + PhoneMetadata getMetadataForNonGeographicalEntity(int countryCallingCode) { + if (!countryCodesForNonGeographicalEntity.contains(countryCallingCode)) { return null; } - PhoneMetadata phoneMetadata = metadataSource.getMetadataForNonGeographicalRegion( + PhoneMetadata phoneMetadata = metadataSource.getMetadataForNonGeographicalEntity( countryCallingCode); ensureMetadataIsNonNull(phoneMetadata, "Missing metadata for country code " + countryCallingCode); diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/FormattingMetadataSource.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/FormattingMetadataSource.java index f4f332cb2..82fcdcfea 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/FormattingMetadataSource.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/FormattingMetadataSource.java @@ -25,7 +25,7 @@ public interface FormattingMetadataSource { * Returns formatting phone metadata for provided country calling code. * *

This method is similar to the one in {@link - * NonGeographicalEntityMetadataSource#getMetadataForNonGeographicalRegion(int)}, except that it + * NonGeographicalEntityMetadataSourceV2#getMetadataForNonGeographicalEntity(int)}, except that it * will not fail for geographical regions, it can be used for both geo- and non-geo entities. * *

In case the provided {@code countryCallingCode} maps to several different regions, only one diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSource.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSource.java index d353ce969..0b9ccc449 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSource.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSource.java @@ -17,5 +17,5 @@ package com.google.i18n.phonenumbers.metadata.source; /** A source of phone metadata split by different regions. */ -public interface MetadataSource extends RegionMetadataSource, NonGeographicalEntityMetadataSource { +public interface MetadataSource extends RegionMetadataSource, NonGeographicalEntityMetadataSource, NonGeographicalEntityMetadataSourceV2 { } diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSourceImpl.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSourceImpl.java index c3d1c7360..9c963eadf 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSourceImpl.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/MetadataSourceImpl.java @@ -49,8 +49,17 @@ public final class MetadataSourceImpl implements MetadataSource { metadataLoader, metadataParser, new CompositeMetadataContainer())); } + /** + * @deprecated Use {@link #getMetadataForNonGeographicalEntity(int)} + */ + @Deprecated @Override public PhoneMetadata getMetadataForNonGeographicalRegion(int countryCallingCode) { + return getMetadataForNonGeographicalEntity(countryCallingCode); + } + + @Override + public PhoneMetadata getMetadataForNonGeographicalEntity(int countryCallingCode) { if (GeoEntityUtility.isGeoEntity(countryCallingCode)) { throw new IllegalArgumentException( countryCallingCode + " calling code belongs to a geo entity"); diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSource.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSource.java index 70db06df0..8e1400dfd 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSource.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSource.java @@ -19,29 +19,14 @@ package com.google.i18n.phonenumbers.metadata.source; import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata; /** - * A source of phone metadata for non-geographical entities. - * - *

Non-geographical entities are phone number ranges that have a country calling code, but either - * do not belong to an actual country (some international services), or belong to a region which has - * a different country calling code from the country it is part of. Examples of such ranges are - * those starting with: - * - *

    - *
  • 800 - country code assigned to the Universal International Freephone Service - *
  • 808 - country code assigned to the International Shared Cost Service - *
  • 870 - country code assigned to the Pitcairn Islands - *
  • ... - *
+ * @deprecated Use {@link NonGeographicalEntityMetadataSourceV2} */ +@Deprecated public interface NonGeographicalEntityMetadataSource { /** - * Gets phone metadata for a non-geographical entity. - * - * @param countryCallingCode the country calling code. - * @return the phone metadata for that entity, or null if there is none. - * @throws IllegalArgumentException if provided {@code countryCallingCode} does not belong to a - * non-geographical entity + * @deprecated use {@link NonGeographicalEntityMetadataSourceV2#getMetadataForNonGeographicalEntity(int)} */ + @Deprecated PhoneMetadata getMetadataForNonGeographicalRegion(int countryCallingCode); -} +} \ No newline at end of file diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSourceV2.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSourceV2.java new file mode 100644 index 000000000..37cf81473 --- /dev/null +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/metadata/source/NonGeographicalEntityMetadataSourceV2.java @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2022 The Libphonenumber Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.i18n.phonenumbers.metadata.source; + +import com.google.i18n.phonenumbers.Phonemetadata.PhoneMetadata; + +/** + * A source of phone metadata for non-geographical entities. + * + *

Non-geographical entities are phone number ranges that have a country calling code, but either + * do not belong to an actual country (some international services), or belong to a region which has + * a different country calling code from the country it is part of. Examples of such ranges are + * those starting with: + * + *

    + *
  • 800 - country code assigned to the Universal International Freephone Service + *
  • 808 - country code assigned to the International Shared Cost Service + *
  • 870 - country code assigned to the Pitcairn Islands + *
  • ... + *
+ */ +public interface NonGeographicalEntityMetadataSourceV2 { + + /** + * Gets phone metadata for a non-geographical entity. + * + * @param countryCallingCode the country calling code. + * @return the phone metadata for that entity, or null if there is none. + * @throws IllegalArgumentException if provided {@code countryCallingCode} does not belong to a + * non-geographical entity + */ + PhoneMetadata getMetadataForNonGeographicalEntity(int countryCallingCode); +} diff --git a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java index 6bdef41a7..66835bc4f 100644 --- a/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java +++ b/java/libphonenumber/test/com/google/i18n/phonenumbers/PhoneNumberUtilTest.java @@ -161,7 +161,7 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { public void testGetInstanceLoadBadMetadata() { assertNull(phoneUtil.getMetadataForRegion("No Such Region")); - assertNull(phoneUtil.getMetadataForNonGeographicalRegion(-1)); + assertNull(phoneUtil.getMetadataForNonGeographicalEntity(-1)); } public void testGetSupportedTypesForRegion() { @@ -262,7 +262,7 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { } public void testGetInstanceLoadInternationalTollFreeMetadata() { - PhoneMetadata metadata = phoneUtil.getMetadataForNonGeographicalRegion(800); + PhoneMetadata metadata = phoneUtil.getMetadataForNonGeographicalEntity(800); assertEquals("001", metadata.getId()); assertEquals(800, metadata.getCountryCode()); assertEquals("$1 $2", metadata.getNumberFormat(0).getFormat()); @@ -3247,8 +3247,8 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { assertNull(phoneUtil.getMetadataForRegion(RegionCode.ZZ)); } - public void testGetMetadataForNonGeographicalRegionForGeoRegion_shouldBeNull() { - assertNull(phoneUtil.getMetadataForNonGeographicalRegion(/* countryCallingCode = */ 1)); + public void testGetMetadataForNonGeographicalEntityForGeoRegion_shouldBeNull() { + assertNull(phoneUtil.getMetadataForNonGeographicalEntity(/* countryCallingCode = */ 1)); } public void testGetMetadataForRegionForMissingMetadata() { @@ -3262,13 +3262,13 @@ public class PhoneNumberUtilTest extends TestMetadataTestCase { }); } - public void testGetMetadataForNonGeographicalRegionForMissingMetadata() { + public void testGetMetadataForNonGeographicalEntityForMissingMetadata() { assertThrows( MissingMetadataException.class, new ThrowingRunnable() { @Override public void run() { - phoneNumberUtilWithMissingMetadata.getMetadataForNonGeographicalRegion(800); + phoneNumberUtilWithMissingMetadata.getMetadataForNonGeographicalEntity(800); } }); } From 25e5548b42099523bc1b4fae80335fbecff1fd38 Mon Sep 17 00:00:00 2001 From: karoljk Date: Thu, 19 Sep 2024 07:21:00 +0000 Subject: [PATCH 2/8] Modify pending_code_changes.txt Added ( - Renamed NonGeographicalRegion to NonGeographicalEntity. - Created a new interface called NonGeographicalEntityMetadataSourceV2) into the file. --- pending_code_changes.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pending_code_changes.txt b/pending_code_changes.txt index 8b1378917..7de88c8fc 100644 --- a/pending_code_changes.txt +++ b/pending_code_changes.txt @@ -1 +1,3 @@ - +Code changes: + - Renamed NonGeographicalRegion to NonGeographicalEntity. + - Created a new interface called NonGeographicalEntityMetadataSourceV2 \ No newline at end of file From e6c61b594cd621d470793586f4b51f329fccdeba Mon Sep 17 00:00:00 2001 From: karoljk Date: Thu, 19 Sep 2024 07:32:11 +0000 Subject: [PATCH 3/8] Reform @deprecated anotation Changed @deprecated use the following... to just @deprecated Use... to make every @deprecated comment the same. --- .../src/com/google/i18n/phonenumbers/PhoneNumberUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java index 4d2084adf..cdb32ebb8 100644 --- a/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java +++ b/java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java @@ -2323,7 +2323,7 @@ public class PhoneNumberUtil { } /** - * @deprecated use the following name {@link #getMetadataForNonGeographicalEntity} + * @deprecated Use {@link #getMetadataForNonGeographicalEntity} */ @Deprecated PhoneMetadata getMetadataForNonGeographicalRegion(int countryCallingCode) { From be17f26001bd19b4042e3775da8605b06e6b348d Mon Sep 17 00:00:00 2001 From: karoljk Date: Tue, 15 Oct 2024 07:41:29 +0000 Subject: [PATCH 4/8] Rename NonGeographicalRegion to NonGeographicalEntity I renamed the NonGeographicalRegion variables and methodes to NonGeographicalEntity because we want to keep the naming the same so its easier to read. This CL is for the C++ version. --- cpp/src/phonenumbers/asyoutypeformatter.cc | 2 +- cpp/src/phonenumbers/phonenumberutil.cc | 10 +++++----- cpp/src/phonenumbers/phonenumberutil.h | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cpp/src/phonenumbers/asyoutypeformatter.cc b/cpp/src/phonenumbers/asyoutypeformatter.cc index 3fd323fa0..88648de54 100644 --- a/cpp/src/phonenumbers/asyoutypeformatter.cc +++ b/cpp/src/phonenumbers/asyoutypeformatter.cc @@ -688,7 +688,7 @@ bool AsYouTypeFormatter::AttemptToExtractCountryCode() { phone_util_.GetRegionCodeForCountryCode(country_code, &new_region_code); if (PhoneNumberUtil::kRegionCodeForNonGeoEntity == new_region_code) { current_metadata_ = - phone_util_.GetMetadataForNonGeographicalRegion(country_code); + phone_util_.GetMetadataForNonGeographicalEntity(country_code); } else if (new_region_code != default_country_) { current_metadata_ = GetMetadataForRegion(new_region_code); } diff --git a/cpp/src/phonenumbers/phonenumberutil.cc b/cpp/src/phonenumbers/phonenumberutil.cc index f1442974f..aa00e7bd9 100644 --- a/cpp/src/phonenumbers/phonenumberutil.cc +++ b/cpp/src/phonenumbers/phonenumberutil.cc @@ -974,7 +974,7 @@ void PhoneNumberUtil::GetSupportedTypesForNonGeoEntity( std::set* types) const { DCHECK(types); const PhoneMetadata* metadata = - GetMetadataForNonGeographicalRegion(country_calling_code); + GetMetadataForNonGeographicalEntity(country_calling_code); if (metadata == NULL) { LOG(WARNING) << "Unknown country calling code for a non-geographical " << "entity provided: " @@ -1105,7 +1105,7 @@ const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegion( return NULL; } -const PhoneMetadata* PhoneNumberUtil::GetMetadataForNonGeographicalRegion( +const PhoneMetadata* PhoneNumberUtil::GetMetadataForNonGeographicalEntity( int country_calling_code) const { absl::node_hash_map::const_iterator it = country_code_to_non_geographical_metadata_map_->find( @@ -1257,7 +1257,7 @@ void PhoneNumberUtil::FormatNationalNumberWithCarrierCode( const PhoneMetadata* PhoneNumberUtil::GetMetadataForRegionOrCallingCode( int country_calling_code, const string& region_code) const { return kRegionCodeForNonGeoEntity == region_code - ? GetMetadataForNonGeographicalRegion(country_calling_code) + ? GetMetadataForNonGeographicalEntity(country_calling_code) : GetMetadataForRegion(region_code); } @@ -2067,7 +2067,7 @@ bool PhoneNumberUtil::GetExampleNumberForType( it != global_network_calling_codes.end(); ++it) { int country_calling_code = *it; const PhoneMetadata* metadata = - GetMetadataForNonGeographicalRegion(country_calling_code); + GetMetadataForNonGeographicalEntity(country_calling_code); const PhoneNumberDesc* desc = GetNumberDescByType(*metadata, type); if (desc->has_example_number()) { ErrorType success = Parse(StrCat(kPlusSign, @@ -2090,7 +2090,7 @@ bool PhoneNumberUtil::GetExampleNumberForNonGeoEntity( int country_calling_code, PhoneNumber* number) const { DCHECK(number); const PhoneMetadata* metadata = - GetMetadataForNonGeographicalRegion(country_calling_code); + GetMetadataForNonGeographicalEntity(country_calling_code); if (metadata) { // For geographical entities, fixed-line data is always present. However, // for non-geographical entities, this is not the case, so we have to go diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index 14cfc670c..ea6102507 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -865,6 +865,9 @@ class PhoneNumberUtil : public Singleton { const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalRegion( int country_calling_code) const; + const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalEntity( + int country_calling_code) const; + const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegionOrCallingCode( int country_calling_code, const string& region_code) const; From eeda4b489962b5fd5574d8c956eeab5c40549310 Mon Sep 17 00:00:00 2001 From: karoljk Date: Fri, 25 Oct 2024 07:33:21 +0000 Subject: [PATCH 5/8] finish renaming NonGeoRegions to NonGeoEntities --- cpp/test/phonenumbers/phonenumberutil_test.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 4f6990349..00ac3ce58 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -66,7 +66,12 @@ class PhoneNumberUtilTest : public testing::Test { const PhoneMetadata* GetMetadataForNonGeographicalRegion( int country_code) const { - return phone_util_.GetMetadataForNonGeographicalRegion(country_code); + return phone_util_.GetMetadataForNonGeographicalEntity(country_code); + } + + const PhoneMetadata* GetMetadataForNonGeographicalEntity( + int country_code) const { + return phone_util_.GetMetadataForNonGeographicalEntity(country_code); } void ExtractPossibleNumber(const string& number, @@ -342,6 +347,7 @@ TEST_F(PhoneNumberUtilTest, GetInstanceLoadARMetadata) { TEST_F(PhoneNumberUtilTest, GetInstanceLoadInternationalTollFreeMetadata) { const PhoneMetadata* metadata = GetMetadataForNonGeographicalRegion(800); + const PhoneMetadata* metadata = GetMetadataForNonGeographicalEntity(800); EXPECT_FALSE(metadata == NULL); EXPECT_EQ("001", metadata->id()); EXPECT_EQ(800, metadata->country_code()); From 426d869c859214db6838e22adf62507a9165614b Mon Sep 17 00:00:00 2001 From: karoljk Date: Wed, 27 Nov 2024 13:49:21 +0000 Subject: [PATCH 6/8] Rewrote renaming for geographicalEntity --- cpp/test/phonenumbers/phonenumberutil_test.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 00ac3ce58..12ed75b2d 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -347,7 +347,6 @@ TEST_F(PhoneNumberUtilTest, GetInstanceLoadARMetadata) { TEST_F(PhoneNumberUtilTest, GetInstanceLoadInternationalTollFreeMetadata) { const PhoneMetadata* metadata = GetMetadataForNonGeographicalRegion(800); - const PhoneMetadata* metadata = GetMetadataForNonGeographicalEntity(800); EXPECT_FALSE(metadata == NULL); EXPECT_EQ("001", metadata->id()); EXPECT_EQ(800, metadata->country_code()); From 32e07651a063587ee64d10334fc9a30b477f9dba Mon Sep 17 00:00:00 2001 From: karoljk Date: Wed, 27 Nov 2024 13:51:03 +0000 Subject: [PATCH 7/8] Rename Region to Entity in GetMetadataForNonGeographicalEntity --- cpp/test/phonenumbers/phonenumberutil_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 12ed75b2d..985578a31 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -346,7 +346,7 @@ TEST_F(PhoneNumberUtilTest, GetInstanceLoadARMetadata) { } TEST_F(PhoneNumberUtilTest, GetInstanceLoadInternationalTollFreeMetadata) { - const PhoneMetadata* metadata = GetMetadataForNonGeographicalRegion(800); + const PhoneMetadata* metadata = GetMetadataForNonGeographicalEntity(800); EXPECT_FALSE(metadata == NULL); EXPECT_EQ("001", metadata->id()); EXPECT_EQ(800, metadata->country_code()); From 75c58a81416ff223448a8121ce38617349c0fb8e Mon Sep 17 00:00:00 2001 From: KarolJakubKrawiec Date: Thu, 12 Dec 2024 09:16:42 +0100 Subject: [PATCH 8/8] Correct mistakes in pull request In this commit I have delete unnecessary code. --- cpp/src/phonenumbers/phonenumberutil.h | 3 --- cpp/test/phonenumbers/phonenumberutil_test.cc | 5 ----- 2 files changed, 8 deletions(-) diff --git a/cpp/src/phonenumbers/phonenumberutil.h b/cpp/src/phonenumbers/phonenumberutil.h index ea6102507..d4e2be813 100644 --- a/cpp/src/phonenumbers/phonenumberutil.h +++ b/cpp/src/phonenumbers/phonenumberutil.h @@ -862,9 +862,6 @@ class PhoneNumberUtil : public Singleton { const i18n::phonenumbers::PhoneMetadata* GetMetadataForRegion( const string& region_code) const; - const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalRegion( - int country_calling_code) const; - const i18n::phonenumbers::PhoneMetadata* GetMetadataForNonGeographicalEntity( int country_calling_code) const; diff --git a/cpp/test/phonenumbers/phonenumberutil_test.cc b/cpp/test/phonenumbers/phonenumberutil_test.cc index 985578a31..904e4d8f3 100644 --- a/cpp/test/phonenumbers/phonenumberutil_test.cc +++ b/cpp/test/phonenumbers/phonenumberutil_test.cc @@ -64,11 +64,6 @@ class PhoneNumberUtilTest : public testing::Test { return phone_util_.GetMetadataForRegion(region_code); } - const PhoneMetadata* GetMetadataForNonGeographicalRegion( - int country_code) const { - return phone_util_.GetMetadataForNonGeographicalEntity(country_code); - } - const PhoneMetadata* GetMetadataForNonGeographicalEntity( int country_code) const { return phone_util_.GetMetadataForNonGeographicalEntity(country_code);