-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create new class ParseWithOptions #3730
base: master
Are you sure you want to change the base?
Changes from 5 commits
ed15e47
f5c2748
809f889
45cb5e4
90270c7
5155f58
9d7975a
1a8629e
ddcfb51
2b6d054
65f0f44
35f998d
d9d2ef0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2024 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; | ||
|
||
/** Options for the phone number parser. */ | ||
public class ParsingOptions { | ||
/** | ||
* Returns the region we are expecting the number to be from. This is ignored if the number being | ||
* parsed is written in international format. In case of national format, the country_code will be | ||
* set to the one of this default region. If the number is guaranteed to start with a '+' followed | ||
* by the country calling code, then RegionCode.ZZ or null can be supplied. | ||
*/ | ||
|
||
private boolean hasDefaultRegion; | ||
private String defaultRegion_ = null; | ||
public boolean hasDefaultRegion() { return hasDefaultRegion; } | ||
public String getDefaultRegion() { return defaultRegion_; } | ||
public ParsingOptions setDefaultRegion(String value) { | ||
hasDefaultRegion = (value != null); | ||
defaultRegion_ = value; | ||
return this; | ||
} | ||
|
||
/** | ||
* Returns whether the raw input should be kept in the PhoneNumber object. If true, the raw_input | ||
* field and country_code_source fields will be populated. | ||
*/ | ||
private boolean hasKeepRawInput; | ||
private boolean keepRawInput_ = false; | ||
public boolean hasKeepRawInput() { return hasKeepRawInput; } | ||
public boolean isKeepRawInput() { return keepRawInput_; } | ||
public ParsingOptions setKeepRawInput(boolean value) { | ||
if(value == false) { | ||
|
||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this unneeded if-statement. |
||
hasKeepRawInput = true; | ||
keepRawInput_ = value; | ||
return this; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See above comment regarding the comments. |
||
|
||
public ParsingOptions withDefaultRegion(String regionCode) { | ||
return setDefaultRegion(regionCode); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we aren't using a Builder here creating a |
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you move the javadoc above
getDefaultRegion
?