Class PhoneNumber

java.lang.Object
com.google.protobuf.AbstractMessageLite
com.google.protobuf.AbstractMessage
com.google.protobuf.GeneratedMessageV3
com.google.type.PhoneNumber
All Implemented Interfaces:
com.google.protobuf.Message, com.google.protobuf.MessageLite, com.google.protobuf.MessageLiteOrBuilder, com.google.protobuf.MessageOrBuilder, PhoneNumberOrBuilder, Serializable

public final class PhoneNumber extends com.google.protobuf.GeneratedMessageV3 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
See Also:
  • 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.GeneratedMessageV3

    com.google.protobuf.GeneratedMessageV3.BuilderParent, com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage,BuilderType extends com.google.protobuf.GeneratedMessageV3.ExtendableBuilder<MessageType,BuilderType>>, com.google.protobuf.GeneratedMessageV3.ExtendableMessage<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage>, com.google.protobuf.GeneratedMessageV3.ExtendableMessageOrBuilder<MessageType extends com.google.protobuf.GeneratedMessageV3.ExtendableMessage>, com.google.protobuf.GeneratedMessageV3.FieldAccessorTable, com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter

    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.GeneratedMessageV3

    alwaysUseFieldBuilders, unknownFields

    Fields inherited from class com.google.protobuf.AbstractMessage

    memoizedSize

    Fields inherited from class com.google.protobuf.AbstractMessageLite

    memoizedHashCode
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
     
     
     
    static final com.google.protobuf.Descriptors.Descriptor
     
    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.
     
    com.google.protobuf.Parser<PhoneNumber>
     
    int
     
    A short code.
    A short code.
    final com.google.protobuf.UnknownFieldSet
     
    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".
    int
     
    boolean
    A short code.
    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
     
    final boolean
     
     
     
     
    newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
     
    protected Object
    newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
     
     
    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>
     
     
    void
    writeTo(com.google.protobuf.CodedOutputStream output)
     

    Methods inherited from class com.google.protobuf.GeneratedMessageV3

    canUseUnsafe, computeStringSize, computeStringSizeNoTag, emptyBooleanList, emptyDoubleList, emptyFloatList, emptyIntList, emptyLongList, getAllFields, getDescriptorForType, getField, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof, internalGetMapField, isStringEmpty, makeExtensionsImmutable, mergeFromAndMakeImmutableInternal, mutableCopy, mutableCopy, mutableCopy, mutableCopy, mutableCopy, newBooleanList, newBuilderForType, newDoubleList, newFloatList, newIntList, newLongList, parseDelimitedWithIOException, parseDelimitedWithIOException, parseUnknownField, parseUnknownFieldProto3, parseWithIOException, parseWithIOException, parseWithIOException, parseWithIOException, serializeBooleanMapTo, serializeIntegerMapTo, serializeLongMapTo, serializeStringMapTo, writeReplace, writeString, writeStringNoTag

    Methods inherited from class com.google.protobuf.AbstractMessage

    findInitializationErrors, getInitializationErrorString, hashBoolean, hashEnum, hashEnumList, hashFields, hashLong, toString

    Methods inherited from class com.google.protobuf.AbstractMessageLite

    addAll, 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.MessageLite

    toByteArray, toByteString, writeDelimitedTo, writeTo

    Methods inherited from interface com.google.protobuf.MessageOrBuilder

    findInitializationErrors, getAllFields, getDescriptorForType, getField, getInitializationErrorString, getOneofFieldDescriptor, getRepeatedField, getRepeatedFieldCount, hasField, hasOneof
  • 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

    • newInstance

      protected Object newInstance(com.google.protobuf.GeneratedMessageV3.UnusedPrivateParameter unused)
      Overrides:
      newInstance in class com.google.protobuf.GeneratedMessageV3
    • getUnknownFields

      public final com.google.protobuf.UnknownFieldSet getUnknownFields()
      Specified by:
      getUnknownFields in interface com.google.protobuf.MessageOrBuilder
      Overrides:
      getUnknownFields in class com.google.protobuf.GeneratedMessageV3
    • getDescriptor

      public static final com.google.protobuf.Descriptors.Descriptor getDescriptor()
    • internalGetFieldAccessorTable

      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable()
      Specified by:
      internalGetFieldAccessorTable in class com.google.protobuf.GeneratedMessageV3
    • 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;
      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;
      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;
      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;
      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;
      Specified by:
      getShortCode in interface PhoneNumberOrBuilder
      Returns:
      The shortCode.
    • getShortCodeOrBuilder

      public PhoneNumber.ShortCodeOrBuilder getShortCodeOrBuilder()
       A short code.
       Reference(s):
        - https://en.wikipedia.org/wiki/Short_code
       
      .google.type.PhoneNumber.ShortCode short_code = 2;
      Specified by:
      getShortCodeOrBuilder in interface PhoneNumberOrBuilder
    • 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;
      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;
      Specified by:
      getExtensionBytes in interface PhoneNumberOrBuilder
      Returns:
      The bytes for extension.
    • isInitialized

      public final boolean isInitialized()
      Specified by:
      isInitialized in interface com.google.protobuf.MessageLiteOrBuilder
      Overrides:
      isInitialized in class com.google.protobuf.GeneratedMessageV3
    • writeTo

      public void writeTo(com.google.protobuf.CodedOutputStream output) throws IOException
      Specified by:
      writeTo in interface com.google.protobuf.MessageLite
      Overrides:
      writeTo in class com.google.protobuf.GeneratedMessageV3
      Throws:
      IOException
    • getSerializedSize

      public int getSerializedSize()
      Specified by:
      getSerializedSize in interface com.google.protobuf.MessageLite
      Overrides:
      getSerializedSize in class com.google.protobuf.GeneratedMessageV3
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface com.google.protobuf.Message
      Overrides:
      equals in class com.google.protobuf.AbstractMessage
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface com.google.protobuf.Message
      Overrides:
      hashCode in class com.google.protobuf.AbstractMessage
    • 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
    • newBuilderForType

      public PhoneNumber.Builder newBuilderForType()
      Specified by:
      newBuilderForType in interface com.google.protobuf.Message
      Specified by:
      newBuilderForType in interface com.google.protobuf.MessageLite
    • newBuilder

      public static PhoneNumber.Builder newBuilder()
    • newBuilder

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

      public PhoneNumber.Builder toBuilder()
      Specified by:
      toBuilder in interface com.google.protobuf.Message
      Specified by:
      toBuilder in interface com.google.protobuf.MessageLite
    • newBuilderForType

      protected PhoneNumber.Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent)
      Specified by:
      newBuilderForType in class com.google.protobuf.GeneratedMessageV3
    • getDefaultInstance

      public static PhoneNumber getDefaultInstance()
    • parser

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

      public com.google.protobuf.Parser<PhoneNumber> getParserForType()
      Specified by:
      getParserForType in interface com.google.protobuf.Message
      Specified by:
      getParserForType in interface com.google.protobuf.MessageLite
      Overrides:
      getParserForType in class com.google.protobuf.GeneratedMessageV3
    • getDefaultInstanceForType

      public PhoneNumber getDefaultInstanceForType()
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageLiteOrBuilder
      Specified by:
      getDefaultInstanceForType in interface com.google.protobuf.MessageOrBuilder