Skip to content

Commit 809f889

Browse files
Add parsingOptions to OpenSource
I have added the new parsing methode ParsingOptions to the OpenSource version.
1 parent f5c2748 commit 809f889

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

java/libphonenumber/src/com/google/i18n/phonenumbers/ParsingOptions.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public class ParsingOptions {
3030
public boolean hasDefaultRegion() { return hasDefaultRegion; }
3131
public String getDefaultRegion() { return defaultRegion_; }
3232
public ParsingOptions setDefaultRegion(String value) {
33-
hasDefaultRegion = (value != null);
33+
if (value == null) {
34+
throw new NullPointerException();
35+
}
36+
hasDefaultRegion = true;
3437
defaultRegion_ = value;
3538
return this;
3639
}

java/libphonenumber/src/com/google/i18n/phonenumbers/PhoneNumberUtil.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,6 +3249,18 @@ public void parseWithOptions(CharSequence numberToParse, ParsingOptions options,
32493249
parseHelper(numberToParse, options.getDefaultRegion(), options.isKeepRawInput(), true, phoneNumber);
32503250
}
32513251

3252+
public PhoneNumber parseWithOptions(CharSequence numberToParse, ParsingOptions options)
3253+
throws NumberParseException {
3254+
PhoneNumber phoneNumber = new PhoneNumber();
3255+
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
3256+
return phoneNumber;
3257+
}
3258+
3259+
public void parseWithOptions(CharSequence numberToParse, ParsingOptions options, PhoneNumber phoneNumber)
3260+
throws NumberParseException {
3261+
parseHelper(numberToParse, options.getDefaultRegion(), options.hasKeepRawInput(), options.hasDefaultRegion(), phoneNumber);
3262+
}
3263+
32523264
/**
32533265
* Returns an iterable over all {@link PhoneNumberMatch PhoneNumberMatches} in {@code text}. This
32543266
* is a shortcut for {@link #findNumbers(CharSequence, String, Leniency, long)

0 commit comments

Comments
 (0)