Close remaining public-API gaps with upstream Java#260
Merged
Conversation
Three follow-ups from comparing the public API against libphonenumber's Java reference (v9.0.31), beyond the overload-suffix renames already done: - geocoding: port the two missing userRegion overloads as GetDescriptionForValidNumberForUserRegion and GetDescriptionForNumberForUserRegion. These omit the country from the description when the number is from the same region as the caller, matching PhoneNumberOfflineGeocoder. Ports the upstream testGetDescriptionForNumberWithUserRegion case (adapted to production data). - phonenumbermatcher: unexport six helpers that are package-private in Java (checkNumberGroupingIsValid, allNumberGroupsRemainGrouped, allNumberGroupsAreExactlyPresent, containsMoreThanOneSlashInNationalNumber, containsOnlyValidXChars, isNationalPrefixPresentIfRequired). They are only used internally by Leniency.Verify and were never part of the Java public API. - enums: reorder the ValidationResult constants to match Java's enum ordinals. Comparisons are identity-based, so behaviour is unchanged; this only aligns the constants' integer values. None of these introduce new divergences from upstream, so SYNC.md and the reconciled-against version are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-ups from comparing this port's public API against libphonenumber's Java reference (v9.0.31), beyond the overload-suffix renames already done in prior PRs.
Changes
1. geocoding: port the missing
userRegionoverloadsJava's
PhoneNumberOfflineGeocoderexposes four public methods; we only had two. Added:GetDescriptionForValidNumberForUserRegion(number, lang, userRegion)GetDescriptionForNumberForUserRegion(number, lang, userRegion)These omit the country from the description when the number is from the same region as the caller (e.g. "California" for a US caller vs "United States" for a GB caller), otherwise returning the localized country name. Ported the upstream
testGetDescriptionForNumberWithUserRegioncase, adapted to the production geocoding data.New public API — note the
…ForUserRegionsuffix naming for the Java overloads.2. phonenumbermatcher: unexport six helpers
checkNumberGroupingIsValid,allNumberGroupsRemainGrouped,allNumberGroupsAreExactlyPresent,containsMoreThanOneSlashInNationalNumber,containsOnlyValidXChars,isNationalPrefixPresentIfRequiredare package-private in Java and only used internally byLeniency.Verify. They were exported here but never part of Java's public surface.Breaking for any external caller that imported these — they are no longer exported.
3. enums: reorder
ValidationResultto match Java ordinalsNew order:
IS_POSSIBLE, IS_POSSIBLE_LOCAL_ONLY, INVALID_COUNTRY_CODE, TOO_SHORT, INVALID_LENGTH, TOO_LONG. Comparisons are identity-based throughout, so behaviour is unchanged; this only aligns the constants' integer values with the Java enum.Notes
None of these introduce new divergences from upstream, so
SYNC.mdand the reconciled-against version (v9.0.31) are unchanged.Testing
go build ./...,go vet ./...,gofmt, andgo test ./...all pass.