@@ -3136,7 +3136,9 @@ private boolean checkRegionForParsing(CharSequence numberToParse, String default
31363136 * @throws NumberParseException if the string is not considered to be a viable phone number (e.g.
31373137 * too few or too many digits) or if no default region was supplied and the number is not in
31383138 * international format (does not start with +)
3139+ * @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions)} instead.
31393140 */
3141+ @ Deprecated
31403142 public PhoneNumber parse (CharSequence numberToParse , String defaultRegion )
31413143 throws NumberParseException {
31423144 PhoneNumber phoneNumber = new PhoneNumber ();
@@ -3147,7 +3149,9 @@ public PhoneNumber parse(CharSequence numberToParse, String defaultRegion)
31473149 /**
31483150 * Same as {@link #parse(CharSequence, String)}, but accepts mutable PhoneNumber as a
31493151 * parameter to decrease object creation when invoked many times.
3152+ * @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions, PhoneNumber)} instead.
31503153 */
3154+ @ Deprecated
31513155 public void parse (CharSequence numberToParse , String defaultRegion , PhoneNumber phoneNumber )
31523156 throws NumberParseException {
31533157 parseHelper (numberToParse , defaultRegion , false , true , phoneNumber );
@@ -3166,7 +3170,9 @@ public void parse(CharSequence numberToParse, String defaultRegion, PhoneNumber
31663170 * @return a phone number proto buffer filled with the parsed number
31673171 * @throws NumberParseException if the string is not considered to be a viable phone number or if
31683172 * no default region was supplied
3173+ * @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions)} instead.
31693174 */
3175+ @ Deprecated
31703176 public PhoneNumber parseAndKeepRawInput (CharSequence numberToParse , String defaultRegion )
31713177 throws NumberParseException {
31723178 PhoneNumber phoneNumber = new PhoneNumber ();
@@ -3177,13 +3183,26 @@ public PhoneNumber parseAndKeepRawInput(CharSequence numberToParse, String defau
31773183 /**
31783184 * Same as{@link #parseAndKeepRawInput(CharSequence, String)}, but accepts a mutable
31793185 * PhoneNumber as a parameter to decrease object creation when invoked many times.
3186+ * @deprecated Use {@link #parseWithOptions(CharSequence, ParsingOptions, PhoneNumber)} instead.
31803187 */
3181- public void parseAndKeepRawInput ( CharSequence numberToParse , String defaultRegion ,
3182- PhoneNumber phoneNumber )
3188+ @ Deprecated
3189+ public void parseAndKeepRawInput ( CharSequence numberToParse , String defaultRegion , PhoneNumber phoneNumber )
31833190 throws NumberParseException {
31843191 parseHelper (numberToParse , defaultRegion , true , true , phoneNumber );
31853192 }
31863193
3194+ public PhoneNumber parseWithOptions (CharSequence numberToParse , ParsingOptions options )
3195+ throws NumberParseException {
3196+ PhoneNumber phoneNumber = new PhoneNumber ();
3197+ parseHelper (numberToParse , options .getDefaultRegion (), options .hasKeepRawInput (), options .hasDefaultRegion (), phoneNumber );
3198+ return phoneNumber ;
3199+ }
3200+
3201+ public void parseWithOptions (CharSequence numberToParse , ParsingOptions options , PhoneNumber phoneNumber )
3202+ throws NumberParseException {
3203+ parseHelper (numberToParse , options .getDefaultRegion (), options .hasKeepRawInput (), options .hasDefaultRegion (), phoneNumber );
3204+ }
3205+
31873206 /**
31883207 * Returns an iterable over all {@link PhoneNumberMatch PhoneNumberMatches} in {@code text}. This
31893208 * is a shortcut for {@link #findNumbers(CharSequence, String, Leniency, long)
0 commit comments