Class PhoneNumber

java.lang.Object
com.google.protobuf.AbstractMessageLite<MessageType,BuilderType>
com.google.protobuf.GeneratedMessageLite<PhoneNumber,PhoneNumber.Builder>
com.google.type.PhoneNumber
All Implemented Interfaces:
com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder, PhoneNumberOrBuilder

public final class PhoneNumber extends com.google.protobuf.GeneratedMessageLite<PhoneNumber,PhoneNumber.Builder> implements PhoneNumberOrBuilder
 An object representing a phone number, suitable as an API wire format.

 This representation:

 - should not be used for locale-specific formatting of a phone number, such
 as "+1 (650) 253-0000 ext. 123"

 - is not designed for efficient storage
 - may not be suitable for dialing - specialized libraries (see references)
 should be used to parse the number for that purpose

 To do something meaningful with this number, such as format it for various
 use-cases, convert it to an `i18n.phonenumbers.PhoneNumber` object first.

 For instance, in Java this would be:

 com.google.type.PhoneNumber wireProto =
 com.google.type.PhoneNumber.newBuilder().build();
 com.google.i18n.phonenumbers.Phonenumber.PhoneNumber phoneNumber =
 PhoneNumberUtil.getInstance().parse(wireProto.getE164Number(), "ZZ");
 if (!wireProto.getExtension().isEmpty()) {
 phoneNumber.setExtension(wireProto.getExtension());
 }

 Reference(s):
 - https://github.com/google/libphonenumber
 
Protobuf type google.type.PhoneNumber
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static final class 
    An object representing a phone number, suitable as an API wire format.
    static enum 
     
    static final class 
    An object representing a short code, which is a phone number that is typically much shorter than regular phone numbers and can be used to address messages in MMS and SMS systems, as well as for abbreviated dialing (e.g.
    static interface 
     

    Nested classes/interfaces inherited from class com.google.protobuf.GeneratedMessageLite

    com.google.protobuf.GeneratedMessageLite.DefaultInstanceBasedParser<T extends com.google.protobuf.GeneratedMessageLite<T,?>>, com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType,BuilderType>,BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType,BuilderType>>, com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType,BuilderType>,BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType,BuilderType>>, com.google.protobuf.GeneratedMessageLite.ExtendableMessageOrBuilder<MessageType extends com.google.protobuf.GeneratedMessageLite.ExtendableMessage<MessageType,BuilderType>,BuilderType extends com.google.protobuf.GeneratedMessageLite.ExtendableBuilder<MessageType,BuilderType>>, com.google.protobuf.GeneratedMessageLite.GeneratedExtension<ContainingType extends com.google.protobuf.MessageLite,Type extends Object>, com.google.protobuf.GeneratedMessageLite.MethodToInvoke, com.google.protobuf.GeneratedMessageLite.SerializedForm

    Nested classes/interfaces inherited from class com.google.protobuf.AbstractMessageLite

    com.google.protobuf.AbstractMessageLite.InternalOneOfEnum
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
    static final int
     
    static final int
     

    Fields inherited from class com.google.protobuf.GeneratedMessageLite

    unknownFields

    Fields inherited from class com.google.protobuf.AbstractMessageLite

    memoizedHashCode
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final Object
    dynamicMethod(com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1)
     
     
    The phone number, represented as a leading plus sign ('+'), followed by a phone number that uses a relaxed ITU E.164 format consisting of the country calling code (1 to 3 digits) and the subscriber number, with no additional spaces or formatting, e.g.: - correct: "+15552220123" - incorrect: "+1 (555) 222-01234 x123".
    com.google.protobuf.ByteString
    The phone number, represented as a leading plus sign ('+'), followed by a phone number that uses a relaxed ITU E.164 format consisting of the country calling code (1 to 3 digits) and the subscriber number, with no additional spaces or formatting, e.g.: - correct: "+15552220123" - incorrect: "+1 (555) 222-01234 x123".
    The phone number's extension.
    com.google.protobuf.ByteString
    The phone number's extension.
     
    A short code.
    boolean
    The phone number, represented as a leading plus sign ('+'), followed by a phone number that uses a relaxed ITU E.164 format consisting of the country calling code (1 to 3 digits) and the subscriber number, with no additional spaces or formatting, e.g.: - correct: "+15552220123" - incorrect: "+1 (555) 222-01234 x123".
    boolean
    A short code.
     
     
     
    parseDelimitedFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    parseFrom(byte[] data)
     
    parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    parseFrom(com.google.protobuf.ByteString data)
     
    parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    parseFrom(com.google.protobuf.CodedInputStream input)
     
    parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
     
    parseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
     
    parseFrom(ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry)
     
    static com.google.protobuf.Parser<PhoneNumber>
     

    Methods inherited from class com.google.protobuf.GeneratedMessageLite

    createBuilder, createBuilder, dynamicMethod, dynamicMethod, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, emptyProtobufList, equals, getDefaultInstanceForType, getParserForType, getSerializedSize, hashCode, isInitialized, isInitialized, makeImmutable, mergeLengthDelimitedField, mergeUnknownFields, mergeVarintField, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBuilderForType, newMessageInfo, newRepeatedGeneratedExtension, newSingularGeneratedExtension, parseDelimitedFrom, parseDelimitedFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parseFrom, parsePartialFrom, parseUnknownField, registerDefaultInstance, toBuilder, toString, writeTo

    Methods inherited from class com.google.protobuf.AbstractMessageLite

    addAll, checkByteStringIsUtf8, toByteArray, toByteString, writeDelimitedTo, writeTo

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.google.protobuf.MessageLiteOrBuilder

    getDefaultInstanceForType, isInitialized
  • Field Details

    • E164_NUMBER_FIELD_NUMBER

      public static final int E164_NUMBER_FIELD_NUMBER
      See Also:
    • SHORT_CODE_FIELD_NUMBER

      public static final int SHORT_CODE_FIELD_NUMBER
      See Also:
    • EXTENSION_FIELD_NUMBER

      public static final int EXTENSION_FIELD_NUMBER
      See Also:
  • Method Details

    • getKindCase

      public PhoneNumber.KindCase getKindCase()
      Specified by:
      getKindCase in interface PhoneNumberOrBuilder
    • hasE164Number

      public boolean hasE164Number()
       The phone number, represented as a leading plus sign ('+'), followed by a
       phone number that uses a relaxed ITU E.164 format consisting of the
       country calling code (1 to 3 digits) and the subscriber number, with no
       additional spaces or formatting, e.g.:
       - correct: "+15552220123"
       - incorrect: "+1 (555) 222-01234 x123".
      
       The ITU E.164 format limits the latter to 12 digits, but in practice not
       all countries respect that, so we relax that restriction here.
       National-only numbers are not allowed.
      
       References:
       - https://www.itu.int/rec/T-REC-E.164-201011-I
       - https://en.wikipedia.org/wiki/E.164.
       - https://en.wikipedia.org/wiki/List_of_country_calling_codes
       
      string e164_number = 1 [json_name = "e164Number"];
      Specified by:
      hasE164Number in interface PhoneNumberOrBuilder
      Returns:
      Whether the e164Number field is set.
    • getE164Number

      public String getE164Number()
       The phone number, represented as a leading plus sign ('+'), followed by a
       phone number that uses a relaxed ITU E.164 format consisting of the
       country calling code (1 to 3 digits) and the subscriber number, with no
       additional spaces or formatting, e.g.:
       - correct: "+15552220123"
       - incorrect: "+1 (555) 222-01234 x123".
      
       The ITU E.164 format limits the latter to 12 digits, but in practice not
       all countries respect that, so we relax that restriction here.
       National-only numbers are not allowed.
      
       References:
       - https://www.itu.int/rec/T-REC-E.164-201011-I
       - https://en.wikipedia.org/wiki/E.164.
       - https://en.wikipedia.org/wiki/List_of_country_calling_codes
       
      string e164_number = 1 [json_name = "e164Number"];
      Specified by:
      getE164Number in interface PhoneNumberOrBuilder
      Returns:
      The e164Number.
    • getE164NumberBytes

      public com.google.protobuf.ByteString getE164NumberBytes()
       The phone number, represented as a leading plus sign ('+'), followed by a
       phone number that uses a relaxed ITU E.164 format consisting of the
       country calling code (1 to 3 digits) and the subscriber number, with no
       additional spaces or formatting, e.g.:
       - correct: "+15552220123"
       - incorrect: "+1 (555) 222-01234 x123".
      
       The ITU E.164 format limits the latter to 12 digits, but in practice not
       all countries respect that, so we relax that restriction here.
       National-only numbers are not allowed.
      
       References:
       - https://www.itu.int/rec/T-REC-E.164-201011-I
       - https://en.wikipedia.org/wiki/E.164.
       - https://en.wikipedia.org/wiki/List_of_country_calling_codes
       
      string e164_number = 1 [json_name = "e164Number"];
      Specified by:
      getE164NumberBytes in interface PhoneNumberOrBuilder
      Returns:
      The bytes for e164Number.
    • hasShortCode

      public boolean hasShortCode()
       A short code.
      
       Reference(s):
       - https://en.wikipedia.org/wiki/Short_code
       
      .google.type.PhoneNumber.ShortCode short_code = 2 [json_name = "shortCode"];
      Specified by:
      hasShortCode in interface PhoneNumberOrBuilder
      Returns:
      Whether the shortCode field is set.
    • getShortCode

      public PhoneNumber.ShortCode getShortCode()
       A short code.
      
       Reference(s):
       - https://en.wikipedia.org/wiki/Short_code
       
      .google.type.PhoneNumber.ShortCode short_code = 2 [json_name = "shortCode"];
      Specified by:
      getShortCode in interface PhoneNumberOrBuilder
      Returns:
      The shortCode.
    • getExtension

      public String getExtension()
       The phone number's extension. The extension is not standardized in ITU
       recommendations, except for being defined as a series of numbers with a
       maximum length of 40 digits. Other than digits, some other dialing
       characters such as ',' (indicating a wait) or '#' may be stored here.
      
       Note that no regions currently use extensions with short codes, so this
       field is normally only set in conjunction with an E.164 number. It is held
       separately from the E.164 number to allow for short code extensions in the
       future.
       
      string extension = 3 [json_name = "extension"];
      Specified by:
      getExtension in interface PhoneNumberOrBuilder
      Returns:
      The extension.
    • getExtensionBytes

      public com.google.protobuf.ByteString getExtensionBytes()
       The phone number's extension. The extension is not standardized in ITU
       recommendations, except for being defined as a series of numbers with a
       maximum length of 40 digits. Other than digits, some other dialing
       characters such as ',' (indicating a wait) or '#' may be stored here.
      
       Note that no regions currently use extensions with short codes, so this
       field is normally only set in conjunction with an E.164 number. It is held
       separately from the E.164 number to allow for short code extensions in the
       future.
       
      string extension = 3 [json_name = "extension"];
      Specified by:
      getExtensionBytes in interface PhoneNumberOrBuilder
      Returns:
      The bytes for extension.
    • parseFrom

      public static PhoneNumber parseFrom(ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException
      Throws:
      com.google.protobuf.InvalidProtocolBufferException
    • parseFrom

      public static PhoneNumber parseFrom(InputStream input) throws IOException
      Throws:
      IOException
    • parseFrom

      public static PhoneNumber parseFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Throws:
      IOException
    • parseDelimitedFrom

      public static PhoneNumber parseDelimitedFrom(InputStream input) throws IOException
      Throws:
      IOException
    • parseDelimitedFrom

      public static PhoneNumber parseDelimitedFrom(InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Throws:
      IOException
    • parseFrom

      public static PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input) throws IOException
      Throws:
      IOException
    • parseFrom

      public static PhoneNumber parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws IOException
      Throws:
      IOException
    • newBuilder

      public static PhoneNumber.Builder newBuilder()
    • newBuilder

      public static PhoneNumber.Builder newBuilder(PhoneNumber prototype)
    • dynamicMethod

      protected final Object dynamicMethod(com.google.protobuf.GeneratedMessageLite.MethodToInvoke method, Object arg0, Object arg1)
      Specified by:
      dynamicMethod in class com.google.protobuf.GeneratedMessageLite<PhoneNumber,PhoneNumber.Builder>
    • getDefaultInstance

      public static PhoneNumber getDefaultInstance()
    • parser

      public static com.google.protobuf.Parser<PhoneNumber> parser()