Home | History | Annotate | Download | only in phonenumbers
      1 /*
      2  * Copyright (C) 2010 The Libphonenumber Authors
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  * http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /**
     18  * Definition of the class representing metadata for international telephone numbers. This class is
     19  * hand created based on the class file compiled from phonemetadata.proto. Please refer to that file
     20  * for detailed descriptions of the meaning of each field.
     21  *
     22  * <p>WARNING: This API isn't stable. It is considered libphonenumber-internal and can change at any
     23  * time. We only declare it as public for easy inclusion in our build tools not in this package.
     24  * Clients should not refer to this file, we do not commit to support backwards-compatibility or to
     25  * warn about breaking changes.
     26  */
     27 
     28 package com.google.i18n.phonenumbers;
     29 
     30 import java.io.Externalizable;
     31 import java.io.IOException;
     32 import java.io.ObjectInput;
     33 import java.io.ObjectOutput;
     34 
     35 public final class Phonemetadata {
     36   private Phonemetadata() {}
     37   public static class NumberFormat implements Externalizable {
     38     private static final long serialVersionUID = 1;
     39     public NumberFormat() {}
     40 
     41     /**
     42      * Provides a dummy builder to 'emulate' the API of the code generated by the latest version of
     43      * Protocol Buffers. This lets BuildMetadataFromXml class to build with both this hand created
     44      * class and the one generated by the latest version of Protocol Buffers.
     45      */
     46     public static final class Builder extends NumberFormat {
     47       public NumberFormat build() {
     48         return this;
     49       }
     50 
     51       public Builder mergeFrom(NumberFormat other) {
     52         if (other.hasPattern()) {
     53           setPattern(other.getPattern());
     54         }
     55         if (other.hasFormat()) {
     56           setFormat(other.getFormat());
     57         }
     58         for (int i = 0; i < other.leadingDigitsPatternSize(); i++) {
     59           addLeadingDigitsPattern(other.getLeadingDigitsPattern(i));
     60         }
     61         if (other.hasNationalPrefixFormattingRule()) {
     62           setNationalPrefixFormattingRule(other.getNationalPrefixFormattingRule());
     63         }
     64         if (other.hasDomesticCarrierCodeFormattingRule()) {
     65           setDomesticCarrierCodeFormattingRule(other.getDomesticCarrierCodeFormattingRule());
     66         }
     67         if (other.hasNationalPrefixOptionalWhenFormatting()) {
     68           setNationalPrefixOptionalWhenFormatting(other.isNationalPrefixOptionalWhenFormatting());
     69         }
     70         return this;
     71       }
     72     }
     73 
     74     public static Builder newBuilder() {
     75       return new Builder();
     76     }
     77 
     78     // required string pattern = 1;
     79     private boolean hasPattern;
     80     private String pattern_ = "";
     81     public boolean hasPattern() { return hasPattern; }
     82     public String getPattern() { return pattern_; }
     83     public NumberFormat setPattern(String value) {
     84       hasPattern = true;
     85       pattern_ = value;
     86       return this;
     87     }
     88 
     89     // required string format = 2;
     90     private boolean hasFormat;
     91     private String format_ = "";
     92     public boolean hasFormat() { return hasFormat; }
     93     public String getFormat() { return format_; }
     94     public NumberFormat setFormat(String value) {
     95       hasFormat = true;
     96       format_ = value;
     97       return this;
     98     }
     99 
    100     // repeated string leading_digits_pattern = 3;
    101     private java.util.List<String> leadingDigitsPattern_ = new java.util.ArrayList<String>();
    102     public java.util.List<String> leadingDigitPatterns() {
    103       return leadingDigitsPattern_;
    104     }
    105     public int leadingDigitsPatternSize() { return leadingDigitsPattern_.size(); }
    106     public String getLeadingDigitsPattern(int index) {
    107       return leadingDigitsPattern_.get(index);
    108     }
    109     public NumberFormat addLeadingDigitsPattern(String value) {
    110       if (value == null) {
    111         throw new NullPointerException();
    112       }
    113       leadingDigitsPattern_.add(value);
    114       return this;
    115     }
    116 
    117     // optional string national_prefix_formatting_rule = 4;
    118     private boolean hasNationalPrefixFormattingRule;
    119     private String nationalPrefixFormattingRule_ = "";
    120     public boolean hasNationalPrefixFormattingRule() { return hasNationalPrefixFormattingRule; }
    121     public String getNationalPrefixFormattingRule() { return nationalPrefixFormattingRule_; }
    122     public NumberFormat setNationalPrefixFormattingRule(String value) {
    123       hasNationalPrefixFormattingRule = true;
    124       nationalPrefixFormattingRule_ = value;
    125       return this;
    126     }
    127     public NumberFormat clearNationalPrefixFormattingRule() {
    128       hasNationalPrefixFormattingRule = false;
    129       nationalPrefixFormattingRule_ = "";
    130       return this;
    131     }
    132 
    133     // optional bool national_prefix_optional_when_formatting = 6;
    134     private boolean hasNationalPrefixOptionalWhenFormatting;
    135     private boolean nationalPrefixOptionalWhenFormatting_ = false;
    136     public boolean hasNationalPrefixOptionalWhenFormatting() {
    137       return hasNationalPrefixOptionalWhenFormatting; }
    138     public boolean isNationalPrefixOptionalWhenFormatting() {
    139       return nationalPrefixOptionalWhenFormatting_; }
    140     public NumberFormat setNationalPrefixOptionalWhenFormatting(boolean value) {
    141       hasNationalPrefixOptionalWhenFormatting = true;
    142       nationalPrefixOptionalWhenFormatting_ = value;
    143       return this;
    144     }
    145 
    146     // optional string domestic_carrier_code_formatting_rule = 5;
    147     private boolean hasDomesticCarrierCodeFormattingRule;
    148     private String domesticCarrierCodeFormattingRule_ = "";
    149     public boolean hasDomesticCarrierCodeFormattingRule() {
    150       return hasDomesticCarrierCodeFormattingRule; }
    151     public String getDomesticCarrierCodeFormattingRule() {
    152       return domesticCarrierCodeFormattingRule_; }
    153     public NumberFormat setDomesticCarrierCodeFormattingRule(String value) {
    154       hasDomesticCarrierCodeFormattingRule = true;
    155       domesticCarrierCodeFormattingRule_ = value;
    156       return this;
    157     }
    158 
    159     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    160       objectOutput.writeUTF(pattern_);
    161       objectOutput.writeUTF(format_);
    162       int leadingDigitsPatternSize = leadingDigitsPatternSize();
    163       objectOutput.writeInt(leadingDigitsPatternSize);
    164       for (int i = 0; i < leadingDigitsPatternSize; i++) {
    165         objectOutput.writeUTF(leadingDigitsPattern_.get(i));
    166       }
    167 
    168       objectOutput.writeBoolean(hasNationalPrefixFormattingRule);
    169       if (hasNationalPrefixFormattingRule) {
    170         objectOutput.writeUTF(nationalPrefixFormattingRule_);
    171       }
    172       objectOutput.writeBoolean(hasDomesticCarrierCodeFormattingRule);
    173       if (hasDomesticCarrierCodeFormattingRule) {
    174         objectOutput.writeUTF(domesticCarrierCodeFormattingRule_);
    175       }
    176       objectOutput.writeBoolean(nationalPrefixOptionalWhenFormatting_);
    177     }
    178 
    179     public void readExternal(ObjectInput objectInput) throws IOException {
    180       setPattern(objectInput.readUTF());
    181       setFormat(objectInput.readUTF());
    182       int leadingDigitsPatternSize = objectInput.readInt();
    183       for (int i = 0; i < leadingDigitsPatternSize; i++) {
    184         leadingDigitsPattern_.add(objectInput.readUTF());
    185       }
    186       if (objectInput.readBoolean()) {
    187         setNationalPrefixFormattingRule(objectInput.readUTF());
    188       }
    189       if (objectInput.readBoolean()) {
    190         setDomesticCarrierCodeFormattingRule(objectInput.readUTF());
    191       }
    192       setNationalPrefixOptionalWhenFormatting(objectInput.readBoolean());
    193     }
    194   }
    195 
    196   public static class PhoneNumberDesc implements Externalizable {
    197     private static final long serialVersionUID = 1;
    198     public PhoneNumberDesc() {}
    199 
    200     /**
    201      * Provides a dummy builder.
    202      *
    203      * @see NumberFormat.Builder
    204      */
    205     public static final class Builder extends PhoneNumberDesc {
    206       public PhoneNumberDesc build() {
    207         return this;
    208       }
    209 
    210       public Builder mergeFrom(PhoneNumberDesc other) {
    211         if (other.hasNationalNumberPattern()) {
    212           setNationalNumberPattern(other.getNationalNumberPattern());
    213         }
    214         if (other.hasPossibleNumberPattern()) {
    215           setPossibleNumberPattern(other.getPossibleNumberPattern());
    216         }
    217         for (int i = 0; i < other.getPossibleLengthCount(); i++) {
    218           addPossibleLength(other.getPossibleLength(i));
    219         }
    220         for (int i = 0; i < other.getPossibleLengthLocalOnlyCount(); i++) {
    221           addPossibleLengthLocalOnly(other.getPossibleLengthLocalOnly(i));
    222         }
    223         if (other.hasExampleNumber()) {
    224           setExampleNumber(other.getExampleNumber());
    225         }
    226         return this;
    227       }
    228     }
    229 
    230     public static Builder newBuilder() {
    231       return new Builder();
    232     }
    233 
    234     // optional string national_number_pattern = 2;
    235     private boolean hasNationalNumberPattern;
    236     private String nationalNumberPattern_ = "";
    237     public boolean hasNationalNumberPattern() { return hasNationalNumberPattern; }
    238     public String getNationalNumberPattern() { return nationalNumberPattern_; }
    239     public PhoneNumberDesc setNationalNumberPattern(String value) {
    240       hasNationalNumberPattern = true;
    241       nationalNumberPattern_ = value;
    242       return this;
    243     }
    244     public PhoneNumberDesc clearNationalNumberPattern() {
    245       hasNationalNumberPattern = false;
    246       nationalNumberPattern_ = "";
    247       return this;
    248     }
    249 
    250     // optional string possible_number_pattern = 3;
    251     private boolean hasPossibleNumberPattern;
    252     private String possibleNumberPattern_ = "";
    253     public boolean hasPossibleNumberPattern() { return hasPossibleNumberPattern; }
    254     public String getPossibleNumberPattern() { return possibleNumberPattern_; }
    255     public PhoneNumberDesc setPossibleNumberPattern(String value) {
    256       hasPossibleNumberPattern = true;
    257       possibleNumberPattern_ = value;
    258       return this;
    259     }
    260     public PhoneNumberDesc clearPossibleNumberPattern() {
    261       hasPossibleNumberPattern = false;
    262       possibleNumberPattern_ = "";
    263       return this;
    264     }
    265 
    266     // repeated int32 possible_length = 9;
    267     private java.util.List<Integer> possibleLength_ = new java.util.ArrayList<Integer>();
    268     public java.util.List<Integer> getPossibleLengthList() {
    269       return possibleLength_;
    270     }
    271     public int getPossibleLengthCount() { return possibleLength_.size(); }
    272     public int getPossibleLength(int index) {
    273       return possibleLength_.get(index);
    274     }
    275     public PhoneNumberDesc addPossibleLength(int value) {
    276       possibleLength_.add(value);
    277       return this;
    278     }
    279     public PhoneNumberDesc clearPossibleLength() {
    280       possibleLength_.clear();
    281       return this;
    282     }
    283 
    284     // repeated int32 possible_length_local_only = 10;
    285     private java.util.List<Integer> possibleLengthLocalOnly_ = new java.util.ArrayList<Integer>();
    286     public java.util.List<Integer> getPossibleLengthLocalOnlyList() {
    287       return possibleLengthLocalOnly_;
    288     }
    289     public int getPossibleLengthLocalOnlyCount() { return possibleLengthLocalOnly_.size(); }
    290     public int getPossibleLengthLocalOnly(int index) {
    291       return possibleLengthLocalOnly_.get(index);
    292     }
    293     public PhoneNumberDesc addPossibleLengthLocalOnly(int value) {
    294       possibleLengthLocalOnly_.add(value);
    295       return this;
    296     }
    297     public PhoneNumberDesc clearPossibleLengthLocalOnly() {
    298       possibleLengthLocalOnly_.clear();
    299       return this;
    300     }
    301 
    302     // optional string example_number = 6;
    303     private boolean hasExampleNumber;
    304     private String exampleNumber_ = "";
    305     public boolean hasExampleNumber() { return hasExampleNumber; }
    306     public String getExampleNumber() { return exampleNumber_; }
    307     public PhoneNumberDesc setExampleNumber(String value) {
    308       hasExampleNumber = true;
    309       exampleNumber_ = value;
    310       return this;
    311     }
    312     public PhoneNumberDesc clearExampleNumber() {
    313       hasExampleNumber = false;
    314       exampleNumber_ = "";
    315       return this;
    316     }
    317 
    318     public boolean exactlySameAs(PhoneNumberDesc other) {
    319       return nationalNumberPattern_.equals(other.nationalNumberPattern_) &&
    320           possibleNumberPattern_.equals(other.possibleNumberPattern_) &&
    321           possibleLength_.equals(other.possibleLength_) &&
    322           possibleLengthLocalOnly_.equals(other.possibleLengthLocalOnly_) &&
    323           exampleNumber_.equals(other.exampleNumber_);
    324     }
    325 
    326     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    327       objectOutput.writeBoolean(hasNationalNumberPattern);
    328       if (hasNationalNumberPattern) {
    329         objectOutput.writeUTF(nationalNumberPattern_);
    330       }
    331 
    332       objectOutput.writeBoolean(hasPossibleNumberPattern);
    333       if (hasPossibleNumberPattern) {
    334         objectOutput.writeUTF(possibleNumberPattern_);
    335       }
    336 
    337       int possibleLengthSize = getPossibleLengthCount();
    338       objectOutput.writeInt(possibleLengthSize);
    339       for (int i = 0; i < possibleLengthSize; i++) {
    340         objectOutput.writeInt(possibleLength_.get(i));
    341       }
    342 
    343       int possibleLengthLocalOnlySize = getPossibleLengthLocalOnlyCount();
    344       objectOutput.writeInt(possibleLengthLocalOnlySize);
    345       for (int i = 0; i < possibleLengthLocalOnlySize; i++) {
    346         objectOutput.writeInt(possibleLengthLocalOnly_.get(i));
    347       }
    348 
    349       objectOutput.writeBoolean(hasExampleNumber);
    350       if (hasExampleNumber) {
    351         objectOutput.writeUTF(exampleNumber_);
    352       }
    353     }
    354 
    355     public void readExternal(ObjectInput objectInput) throws IOException {
    356       if (objectInput.readBoolean()) {
    357         setNationalNumberPattern(objectInput.readUTF());
    358       }
    359 
    360       if (objectInput.readBoolean()) {
    361         setPossibleNumberPattern(objectInput.readUTF());
    362       }
    363 
    364       int possibleLengthSize = objectInput.readInt();
    365       for (int i = 0; i < possibleLengthSize; i++) {
    366         possibleLength_.add(objectInput.readInt());
    367       }
    368 
    369       int possibleLengthLocalOnlySize = objectInput.readInt();
    370       for (int i = 0; i < possibleLengthLocalOnlySize; i++) {
    371         possibleLengthLocalOnly_.add(objectInput.readInt());
    372       }
    373 
    374       if (objectInput.readBoolean()) {
    375         setExampleNumber(objectInput.readUTF());
    376       }
    377     }
    378   }
    379 
    380   public static class PhoneMetadata implements Externalizable {
    381     private static final long serialVersionUID = 1;
    382     public PhoneMetadata() {}
    383 
    384     /**
    385      * Provides a dummy builder.
    386      *
    387      * @see NumberFormat.Builder
    388      */
    389     public static final class Builder extends PhoneMetadata {
    390       public PhoneMetadata build() {
    391         return this;
    392       }
    393     }
    394     public static Builder newBuilder() {
    395       return new Builder();
    396     }
    397 
    398     // optional PhoneNumberDesc general_desc = 1;
    399     private boolean hasGeneralDesc;
    400     private PhoneNumberDesc generalDesc_ = null;
    401     public boolean hasGeneralDesc() { return hasGeneralDesc; }
    402     public PhoneNumberDesc getGeneralDesc() { return generalDesc_; }
    403     public PhoneMetadata setGeneralDesc(PhoneNumberDesc value) {
    404       if (value == null) {
    405         throw new NullPointerException();
    406       }
    407       hasGeneralDesc = true;
    408       generalDesc_ = value;
    409       return this;
    410     }
    411 
    412     // optional PhoneNumberDesc fixed_line = 2;
    413     private boolean hasFixedLine;
    414     private PhoneNumberDesc fixedLine_ = null;
    415     public boolean hasFixedLine() { return hasFixedLine; }
    416     public PhoneNumberDesc getFixedLine() { return fixedLine_; }
    417     public PhoneMetadata setFixedLine(PhoneNumberDesc value) {
    418       if (value == null) {
    419         throw new NullPointerException();
    420       }
    421       hasFixedLine = true;
    422       fixedLine_ = value;
    423       return this;
    424     }
    425 
    426     // optional PhoneNumberDesc mobile = 3;
    427     private boolean hasMobile;
    428     private PhoneNumberDesc mobile_ = null;
    429     public boolean hasMobile() { return hasMobile; }
    430     public PhoneNumberDesc getMobile() { return mobile_; }
    431     public PhoneMetadata setMobile(PhoneNumberDesc value) {
    432       if (value == null) {
    433         throw new NullPointerException();
    434       }
    435       hasMobile = true;
    436       mobile_ = value;
    437       return this;
    438     }
    439 
    440     // optional PhoneNumberDesc toll_free = 4;
    441     private boolean hasTollFree;
    442     private PhoneNumberDesc tollFree_ = null;
    443     public boolean hasTollFree() { return hasTollFree; }
    444     public PhoneNumberDesc getTollFree() { return tollFree_; }
    445     public PhoneMetadata setTollFree(PhoneNumberDesc value) {
    446       if (value == null) {
    447         throw new NullPointerException();
    448       }
    449       hasTollFree = true;
    450       tollFree_ = value;
    451       return this;
    452     }
    453 
    454     // optional PhoneNumberDesc premium_rate = 5;
    455     private boolean hasPremiumRate;
    456     private PhoneNumberDesc premiumRate_ = null;
    457     public boolean hasPremiumRate() { return hasPremiumRate; }
    458     public PhoneNumberDesc getPremiumRate() { return premiumRate_; }
    459     public PhoneMetadata setPremiumRate(PhoneNumberDesc value) {
    460       if (value == null) {
    461         throw new NullPointerException();
    462       }
    463       hasPremiumRate = true;
    464       premiumRate_ = value;
    465       return this;
    466     }
    467 
    468     // optional PhoneNumberDesc shared_cost = 6;
    469     private boolean hasSharedCost;
    470     private PhoneNumberDesc sharedCost_ = null;
    471     public boolean hasSharedCost() { return hasSharedCost; }
    472     public PhoneNumberDesc getSharedCost() { return sharedCost_; }
    473     public PhoneMetadata setSharedCost(PhoneNumberDesc value) {
    474       if (value == null) {
    475         throw new NullPointerException();
    476       }
    477       hasSharedCost = true;
    478       sharedCost_ = value;
    479       return this;
    480     }
    481 
    482     // optional PhoneNumberDesc personal_number = 7;
    483     private boolean hasPersonalNumber;
    484     private PhoneNumberDesc personalNumber_ = null;
    485     public boolean hasPersonalNumber() { return hasPersonalNumber; }
    486     public PhoneNumberDesc getPersonalNumber() { return personalNumber_; }
    487     public PhoneMetadata setPersonalNumber(PhoneNumberDesc value) {
    488       if (value == null) {
    489         throw new NullPointerException();
    490       }
    491       hasPersonalNumber = true;
    492       personalNumber_ = value;
    493       return this;
    494     }
    495 
    496     // optional PhoneNumberDesc voip = 8;
    497     private boolean hasVoip;
    498     private PhoneNumberDesc voip_ = null;
    499     public boolean hasVoip() { return hasVoip; }
    500     public PhoneNumberDesc getVoip() { return voip_; }
    501     public PhoneMetadata setVoip(PhoneNumberDesc value) {
    502       if (value == null) {
    503         throw new NullPointerException();
    504       }
    505       hasVoip = true;
    506       voip_ = value;
    507       return this;
    508     }
    509 
    510     // optional PhoneNumberDesc pager = 21;
    511     private boolean hasPager;
    512     private PhoneNumberDesc pager_ = null;
    513     public boolean hasPager() { return hasPager; }
    514     public PhoneNumberDesc getPager() { return pager_; }
    515     public PhoneMetadata setPager(PhoneNumberDesc value) {
    516       if (value == null) {
    517         throw new NullPointerException();
    518       }
    519       hasPager = true;
    520       pager_ = value;
    521       return this;
    522     }
    523 
    524     // optional PhoneNumberDesc uan = 25;
    525     private boolean hasUan;
    526     private PhoneNumberDesc uan_ = null;
    527     public boolean hasUan() { return hasUan; }
    528     public PhoneNumberDesc getUan() { return uan_; }
    529     public PhoneMetadata setUan(PhoneNumberDesc value) {
    530       if (value == null) {
    531         throw new NullPointerException();
    532       }
    533       hasUan = true;
    534       uan_ = value;
    535       return this;
    536     }
    537 
    538     // optional PhoneNumberDesc emergency = 27;
    539     private boolean hasEmergency;
    540     private PhoneNumberDesc emergency_ = null;
    541     public boolean hasEmergency() { return hasEmergency; }
    542     public PhoneNumberDesc getEmergency() { return emergency_; }
    543     public PhoneMetadata setEmergency(PhoneNumberDesc value) {
    544       if (value == null) {
    545         throw new NullPointerException();
    546       }
    547       hasEmergency = true;
    548       emergency_ = value;
    549       return this;
    550     }
    551 
    552     // optional PhoneNumberDesc voicemail = 28;
    553     private boolean hasVoicemail;
    554     private PhoneNumberDesc voicemail_ = null;
    555     public boolean hasVoicemail() { return hasVoicemail; }
    556     public PhoneNumberDesc getVoicemail() { return voicemail_; }
    557     public PhoneMetadata setVoicemail(PhoneNumberDesc value) {
    558       if (value == null) {
    559         throw new NullPointerException();
    560       }
    561       hasVoicemail = true;
    562       voicemail_ = value;
    563       return this;
    564     }
    565 
    566     // optional PhoneNumberDesc short_code = 29;
    567     private boolean hasShortCode;
    568     private PhoneNumberDesc shortCode_ = null;
    569     public boolean hasShortCode() { return hasShortCode; }
    570     public PhoneNumberDesc getShortCode() { return shortCode_; }
    571     public PhoneMetadata setShortCode(PhoneNumberDesc value) {
    572       if (value == null) {
    573         throw new NullPointerException();
    574       }
    575       hasShortCode = true;
    576       shortCode_ = value;
    577       return this;
    578     }
    579 
    580     // optional PhoneNumberDesc standard_rate = 30;
    581     private boolean hasStandardRate;
    582     private PhoneNumberDesc standardRate_ = null;
    583     public boolean hasStandardRate() { return hasStandardRate; }
    584     public PhoneNumberDesc getStandardRate() { return standardRate_; }
    585     public PhoneMetadata setStandardRate(PhoneNumberDesc value) {
    586       if (value == null) {
    587         throw new NullPointerException();
    588       }
    589       hasStandardRate = true;
    590       standardRate_ = value;
    591       return this;
    592     }
    593 
    594     // optional PhoneNumberDesc carrier_specific = 31;
    595     private boolean hasCarrierSpecific;
    596     private PhoneNumberDesc carrierSpecific_ = null;
    597     public boolean hasCarrierSpecific() { return hasCarrierSpecific; }
    598     public PhoneNumberDesc getCarrierSpecific() { return carrierSpecific_; }
    599     public PhoneMetadata setCarrierSpecific(PhoneNumberDesc value) {
    600       if (value == null) {
    601         throw new NullPointerException();
    602       }
    603       hasCarrierSpecific = true;
    604       carrierSpecific_ = value;
    605       return this;
    606     }
    607 
    608     // optional PhoneNumberDesc noInternationalDialling = 24;
    609     private boolean hasNoInternationalDialling;
    610     private PhoneNumberDesc noInternationalDialling_ = null;
    611     public boolean hasNoInternationalDialling() { return hasNoInternationalDialling; }
    612     public PhoneNumberDesc getNoInternationalDialling() { return noInternationalDialling_; }
    613     public PhoneMetadata setNoInternationalDialling(PhoneNumberDesc value) {
    614       if (value == null) {
    615         throw new NullPointerException();
    616       }
    617       hasNoInternationalDialling = true;
    618       noInternationalDialling_ = value;
    619       return this;
    620     }
    621 
    622     // required string id = 9;
    623     private boolean hasId;
    624     private String id_ = "";
    625     public boolean hasId() { return hasId; }
    626     public String getId() { return id_; }
    627     public PhoneMetadata setId(String value) {
    628       hasId = true;
    629       id_ = value;
    630       return this;
    631     }
    632 
    633     // optional int32 country_code = 10;
    634     private boolean hasCountryCode;
    635     private int countryCode_ = 0;
    636     public boolean hasCountryCode() { return hasCountryCode; }
    637     public int getCountryCode() { return countryCode_; }
    638     public PhoneMetadata setCountryCode(int value) {
    639       hasCountryCode = true;
    640       countryCode_ = value;
    641       return this;
    642     }
    643 
    644     // optional string international_prefix = 11;
    645     private boolean hasInternationalPrefix;
    646     private String internationalPrefix_ = "";
    647     public boolean hasInternationalPrefix() { return hasInternationalPrefix; }
    648     public String getInternationalPrefix() { return internationalPrefix_; }
    649     public PhoneMetadata setInternationalPrefix(String value) {
    650       hasInternationalPrefix = true;
    651       internationalPrefix_ = value;
    652       return this;
    653     }
    654 
    655     // optional string preferred_international_prefix = 17;
    656     private boolean hasPreferredInternationalPrefix;
    657     private String preferredInternationalPrefix_ = "";
    658     public boolean hasPreferredInternationalPrefix() { return hasPreferredInternationalPrefix; }
    659     public String getPreferredInternationalPrefix() { return preferredInternationalPrefix_; }
    660     public PhoneMetadata setPreferredInternationalPrefix(String value) {
    661       hasPreferredInternationalPrefix = true;
    662       preferredInternationalPrefix_ = value;
    663       return this;
    664     }
    665     public PhoneMetadata clearPreferredInternationalPrefix() {
    666       hasPreferredInternationalPrefix = false;
    667       preferredInternationalPrefix_ = "";
    668       return this;
    669     }
    670 
    671     // optional string national_prefix = 12;
    672     private boolean hasNationalPrefix;
    673     private String nationalPrefix_ = "";
    674     public boolean hasNationalPrefix() { return hasNationalPrefix; }
    675     public String getNationalPrefix() { return nationalPrefix_; }
    676     public PhoneMetadata setNationalPrefix(String value) {
    677       hasNationalPrefix = true;
    678       nationalPrefix_ = value;
    679       return this;
    680     }
    681     public PhoneMetadata clearNationalPrefix() {
    682       hasNationalPrefix = false;
    683       nationalPrefix_ = "";
    684       return this;
    685     }
    686 
    687     // optional string preferred_extn_prefix = 13;
    688     private boolean hasPreferredExtnPrefix;
    689     private String preferredExtnPrefix_ = "";
    690     public boolean hasPreferredExtnPrefix() { return hasPreferredExtnPrefix; }
    691     public String getPreferredExtnPrefix() { return preferredExtnPrefix_; }
    692     public PhoneMetadata setPreferredExtnPrefix(String value) {
    693       hasPreferredExtnPrefix = true;
    694       preferredExtnPrefix_ = value;
    695       return this;
    696     }
    697     public PhoneMetadata clearPreferredExtnPrefix() {
    698       hasPreferredExtnPrefix = false;
    699       preferredExtnPrefix_ = "";
    700       return this;
    701     }
    702 
    703     // optional string national_prefix_for_parsing = 15;
    704     private boolean hasNationalPrefixForParsing;
    705     private String nationalPrefixForParsing_ = "";
    706     public boolean hasNationalPrefixForParsing() { return hasNationalPrefixForParsing; }
    707     public String getNationalPrefixForParsing() { return nationalPrefixForParsing_; }
    708     public PhoneMetadata setNationalPrefixForParsing(String value) {
    709       hasNationalPrefixForParsing = true;
    710       nationalPrefixForParsing_ = value;
    711       return this;
    712     }
    713 
    714     // optional string national_prefix_transform_rule = 16;
    715     private boolean hasNationalPrefixTransformRule;
    716     private String nationalPrefixTransformRule_ = "";
    717     public boolean hasNationalPrefixTransformRule() { return hasNationalPrefixTransformRule; }
    718     public String getNationalPrefixTransformRule() { return nationalPrefixTransformRule_; }
    719     public PhoneMetadata setNationalPrefixTransformRule(String value) {
    720       hasNationalPrefixTransformRule = true;
    721       nationalPrefixTransformRule_ = value;
    722       return this;
    723     }
    724     public PhoneMetadata clearNationalPrefixTransformRule() {
    725       hasNationalPrefixTransformRule = false;
    726       nationalPrefixTransformRule_ = "";
    727       return this;
    728     }
    729 
    730     // optional bool same_mobile_and_fixed_line_pattern = 18 [default = false];
    731     private boolean hasSameMobileAndFixedLinePattern;
    732     private boolean sameMobileAndFixedLinePattern_ = false;
    733     public boolean hasSameMobileAndFixedLinePattern() { return hasSameMobileAndFixedLinePattern; }
    734     public boolean isSameMobileAndFixedLinePattern() { return sameMobileAndFixedLinePattern_; }
    735     public PhoneMetadata setSameMobileAndFixedLinePattern(boolean value) {
    736       hasSameMobileAndFixedLinePattern = true;
    737       sameMobileAndFixedLinePattern_ = value;
    738       return this;
    739     }
    740     public PhoneMetadata clearSameMobileAndFixedLinePattern() {
    741       hasSameMobileAndFixedLinePattern = false;
    742       sameMobileAndFixedLinePattern_ = false;
    743       return this;
    744     }
    745 
    746     // repeated NumberFormat number_format = 19;
    747     private java.util.List<NumberFormat> numberFormat_ = new java.util.ArrayList<NumberFormat>();
    748     public java.util.List<NumberFormat> numberFormats() {
    749       return numberFormat_;
    750     }
    751     public int numberFormatSize() { return numberFormat_.size(); }
    752     public NumberFormat getNumberFormat(int index) {
    753       return numberFormat_.get(index);
    754     }
    755     public PhoneMetadata addNumberFormat(NumberFormat value) {
    756       if (value == null) {
    757         throw new NullPointerException();
    758       }
    759       numberFormat_.add(value);
    760       return this;
    761     }
    762 
    763     // repeated NumberFormat intl_number_format = 20;
    764     private java.util.List<NumberFormat> intlNumberFormat_ =
    765         new java.util.ArrayList<NumberFormat>();
    766     public java.util.List<NumberFormat> intlNumberFormats() {
    767       return intlNumberFormat_;
    768     }
    769     public int intlNumberFormatSize() { return intlNumberFormat_.size(); }
    770     public NumberFormat getIntlNumberFormat(int index) {
    771       return intlNumberFormat_.get(index);
    772     }
    773 
    774     public PhoneMetadata addIntlNumberFormat(NumberFormat value) {
    775       if (value == null) {
    776         throw new NullPointerException();
    777       }
    778       intlNumberFormat_.add(value);
    779       return this;
    780     }
    781     public PhoneMetadata clearIntlNumberFormat() {
    782       intlNumberFormat_.clear();
    783       return this;
    784     }
    785 
    786     // optional bool main_country_for_code = 22 [default = false];
    787     private boolean hasMainCountryForCode;
    788     private boolean mainCountryForCode_ = false;
    789     public boolean hasMainCountryForCode() { return hasMainCountryForCode; }
    790     public boolean isMainCountryForCode() { return mainCountryForCode_; }
    791     // Method that lets this class have the same interface as the one generated by Protocol Buffers
    792     // which is used by C++ build tools.
    793     public boolean getMainCountryForCode() { return mainCountryForCode_; }
    794     public PhoneMetadata setMainCountryForCode(boolean value) {
    795       hasMainCountryForCode = true;
    796       mainCountryForCode_ = value;
    797       return this;
    798     }
    799     public PhoneMetadata clearMainCountryForCode() {
    800       hasMainCountryForCode = false;
    801       mainCountryForCode_ = false;
    802       return this;
    803     }
    804 
    805     // optional string leading_digits = 23;
    806     private boolean hasLeadingDigits;
    807     private String leadingDigits_ = "";
    808     public boolean hasLeadingDigits() { return hasLeadingDigits; }
    809     public String getLeadingDigits() { return leadingDigits_; }
    810     public PhoneMetadata setLeadingDigits(String value) {
    811       hasLeadingDigits = true;
    812       leadingDigits_ = value;
    813       return this;
    814     }
    815 
    816     // optional bool leading_zero_possible = 26 [default = false];
    817     private boolean hasLeadingZeroPossible;
    818     private boolean leadingZeroPossible_ = false;
    819     public boolean hasLeadingZeroPossible() { return hasLeadingZeroPossible; }
    820     public boolean isLeadingZeroPossible() { return leadingZeroPossible_; }
    821     public PhoneMetadata setLeadingZeroPossible(boolean value) {
    822       hasLeadingZeroPossible = true;
    823       leadingZeroPossible_ = value;
    824       return this;
    825     }
    826     public PhoneMetadata clearLeadingZeroPossible() {
    827       hasLeadingZeroPossible = false;
    828       leadingZeroPossible_ = false;
    829       return this;
    830     }
    831 
    832     // optional bool mobile_number_portable_region = 32 [default = false];
    833     private boolean hasMobileNumberPortableRegion;
    834     private boolean mobileNumberPortableRegion_ = false;
    835     public boolean hasMobileNumberPortableRegion() { return hasMobileNumberPortableRegion; }
    836     public boolean isMobileNumberPortableRegion() { return mobileNumberPortableRegion_; }
    837     public PhoneMetadata setMobileNumberPortableRegion(boolean value) {
    838       hasMobileNumberPortableRegion = true;
    839       mobileNumberPortableRegion_ = value;
    840       return this;
    841     }
    842     public PhoneMetadata clearMobileNumberPortableRegion() {
    843       hasMobileNumberPortableRegion = false;
    844       mobileNumberPortableRegion_ = false;
    845       return this;
    846     }
    847 
    848     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    849       objectOutput.writeBoolean(hasGeneralDesc);
    850       if (hasGeneralDesc) {
    851         generalDesc_.writeExternal(objectOutput);
    852       }
    853       objectOutput.writeBoolean(hasFixedLine);
    854       if (hasFixedLine) {
    855         fixedLine_.writeExternal(objectOutput);
    856       }
    857       objectOutput.writeBoolean(hasMobile);
    858       if (hasMobile) {
    859         mobile_.writeExternal(objectOutput);
    860       }
    861       objectOutput.writeBoolean(hasTollFree);
    862       if (hasTollFree) {
    863         tollFree_.writeExternal(objectOutput);
    864       }
    865       objectOutput.writeBoolean(hasPremiumRate);
    866       if (hasPremiumRate) {
    867         premiumRate_.writeExternal(objectOutput);
    868       }
    869       objectOutput.writeBoolean(hasSharedCost);
    870       if (hasSharedCost) {
    871         sharedCost_.writeExternal(objectOutput);
    872       }
    873       objectOutput.writeBoolean(hasPersonalNumber);
    874       if (hasPersonalNumber) {
    875         personalNumber_.writeExternal(objectOutput);
    876       }
    877       objectOutput.writeBoolean(hasVoip);
    878       if (hasVoip) {
    879         voip_.writeExternal(objectOutput);
    880       }
    881       objectOutput.writeBoolean(hasPager);
    882       if (hasPager) {
    883         pager_.writeExternal(objectOutput);
    884       }
    885       objectOutput.writeBoolean(hasUan);
    886       if (hasUan) {
    887         uan_.writeExternal(objectOutput);
    888       }
    889       objectOutput.writeBoolean(hasEmergency);
    890       if (hasEmergency) {
    891         emergency_.writeExternal(objectOutput);
    892       }
    893       objectOutput.writeBoolean(hasVoicemail);
    894       if (hasVoicemail) {
    895         voicemail_.writeExternal(objectOutput);
    896       }
    897       objectOutput.writeBoolean(hasShortCode);
    898       if (hasShortCode) {
    899         shortCode_.writeExternal(objectOutput);
    900       }
    901       objectOutput.writeBoolean(hasStandardRate);
    902       if (hasStandardRate) {
    903         standardRate_.writeExternal(objectOutput);
    904       }
    905       objectOutput.writeBoolean(hasCarrierSpecific);
    906       if (hasCarrierSpecific) {
    907         carrierSpecific_.writeExternal(objectOutput);
    908       }
    909       objectOutput.writeBoolean(hasNoInternationalDialling);
    910       if (hasNoInternationalDialling) {
    911         noInternationalDialling_.writeExternal(objectOutput);
    912       }
    913 
    914       objectOutput.writeUTF(id_);
    915       objectOutput.writeInt(countryCode_);
    916       objectOutput.writeUTF(internationalPrefix_);
    917 
    918       objectOutput.writeBoolean(hasPreferredInternationalPrefix);
    919       if (hasPreferredInternationalPrefix) {
    920         objectOutput.writeUTF(preferredInternationalPrefix_);
    921       }
    922 
    923       objectOutput.writeBoolean(hasNationalPrefix);
    924       if (hasNationalPrefix) {
    925         objectOutput.writeUTF(nationalPrefix_);
    926       }
    927 
    928       objectOutput.writeBoolean(hasPreferredExtnPrefix);
    929       if (hasPreferredExtnPrefix) {
    930         objectOutput.writeUTF(preferredExtnPrefix_);
    931       }
    932 
    933       objectOutput.writeBoolean(hasNationalPrefixForParsing);
    934       if (hasNationalPrefixForParsing) {
    935         objectOutput.writeUTF(nationalPrefixForParsing_);
    936       }
    937 
    938       objectOutput.writeBoolean(hasNationalPrefixTransformRule);
    939       if (hasNationalPrefixTransformRule) {
    940         objectOutput.writeUTF(nationalPrefixTransformRule_);
    941       }
    942 
    943       objectOutput.writeBoolean(sameMobileAndFixedLinePattern_);
    944 
    945       int numberFormatSize = numberFormatSize();
    946       objectOutput.writeInt(numberFormatSize);
    947       for (int i = 0; i < numberFormatSize; i++) {
    948         numberFormat_.get(i).writeExternal(objectOutput);
    949       }
    950 
    951       int intlNumberFormatSize = intlNumberFormatSize();
    952       objectOutput.writeInt(intlNumberFormatSize);
    953       for (int i = 0; i < intlNumberFormatSize; i++) {
    954         intlNumberFormat_.get(i).writeExternal(objectOutput);
    955       }
    956 
    957       objectOutput.writeBoolean(mainCountryForCode_);
    958 
    959       objectOutput.writeBoolean(hasLeadingDigits);
    960       if (hasLeadingDigits) {
    961         objectOutput.writeUTF(leadingDigits_);
    962       }
    963 
    964       objectOutput.writeBoolean(leadingZeroPossible_);
    965 
    966       objectOutput.writeBoolean(mobileNumberPortableRegion_);
    967     }
    968 
    969     public void readExternal(ObjectInput objectInput) throws IOException {
    970       boolean hasDesc = objectInput.readBoolean();
    971       if (hasDesc) {
    972         PhoneNumberDesc desc = new PhoneNumberDesc();
    973         desc.readExternal(objectInput);
    974         setGeneralDesc(desc);
    975       }
    976       hasDesc = objectInput.readBoolean();
    977       if (hasDesc) {
    978         PhoneNumberDesc desc = new PhoneNumberDesc();
    979         desc.readExternal(objectInput);
    980         setFixedLine(desc);
    981       }
    982       hasDesc = objectInput.readBoolean();
    983       if (hasDesc) {
    984         PhoneNumberDesc desc = new PhoneNumberDesc();
    985         desc.readExternal(objectInput);
    986         setMobile(desc);
    987       }
    988       hasDesc = objectInput.readBoolean();
    989       if (hasDesc) {
    990         PhoneNumberDesc desc = new PhoneNumberDesc();
    991         desc.readExternal(objectInput);
    992         setTollFree(desc);
    993       }
    994       hasDesc = objectInput.readBoolean();
    995       if (hasDesc) {
    996         PhoneNumberDesc desc = new PhoneNumberDesc();
    997         desc.readExternal(objectInput);
    998         setPremiumRate(desc);
    999       }
   1000       hasDesc = objectInput.readBoolean();
   1001       if (hasDesc) {
   1002         PhoneNumberDesc desc = new PhoneNumberDesc();
   1003         desc.readExternal(objectInput);
   1004         setSharedCost(desc);
   1005       }
   1006       hasDesc = objectInput.readBoolean();
   1007       if (hasDesc) {
   1008         PhoneNumberDesc desc = new PhoneNumberDesc();
   1009         desc.readExternal(objectInput);
   1010         setPersonalNumber(desc);
   1011       }
   1012       hasDesc = objectInput.readBoolean();
   1013       if (hasDesc) {
   1014         PhoneNumberDesc desc = new PhoneNumberDesc();
   1015         desc.readExternal(objectInput);
   1016         setVoip(desc);
   1017       }
   1018       hasDesc = objectInput.readBoolean();
   1019       if (hasDesc) {
   1020         PhoneNumberDesc desc = new PhoneNumberDesc();
   1021         desc.readExternal(objectInput);
   1022         setPager(desc);
   1023       }
   1024       hasDesc = objectInput.readBoolean();
   1025       if (hasDesc) {
   1026         PhoneNumberDesc desc = new PhoneNumberDesc();
   1027         desc.readExternal(objectInput);
   1028         setUan(desc);
   1029       }
   1030       hasDesc = objectInput.readBoolean();
   1031       if (hasDesc) {
   1032         PhoneNumberDesc desc = new PhoneNumberDesc();
   1033         desc.readExternal(objectInput);
   1034         setEmergency(desc);
   1035       }
   1036       hasDesc = objectInput.readBoolean();
   1037       if (hasDesc) {
   1038         PhoneNumberDesc desc = new PhoneNumberDesc();
   1039         desc.readExternal(objectInput);
   1040         setVoicemail(desc);
   1041       }
   1042       hasDesc = objectInput.readBoolean();
   1043       if (hasDesc) {
   1044         PhoneNumberDesc desc = new PhoneNumberDesc();
   1045         desc.readExternal(objectInput);
   1046         setShortCode(desc);
   1047       }
   1048       hasDesc = objectInput.readBoolean();
   1049       if (hasDesc) {
   1050         PhoneNumberDesc desc = new PhoneNumberDesc();
   1051         desc.readExternal(objectInput);
   1052         setStandardRate(desc);
   1053       }
   1054       hasDesc = objectInput.readBoolean();
   1055       if (hasDesc) {
   1056         PhoneNumberDesc desc = new PhoneNumberDesc();
   1057         desc.readExternal(objectInput);
   1058         setCarrierSpecific(desc);
   1059       }
   1060       hasDesc = objectInput.readBoolean();
   1061       if (hasDesc) {
   1062         PhoneNumberDesc desc = new PhoneNumberDesc();
   1063         desc.readExternal(objectInput);
   1064         setNoInternationalDialling(desc);
   1065       }
   1066 
   1067       setId(objectInput.readUTF());
   1068       setCountryCode(objectInput.readInt());
   1069       setInternationalPrefix(objectInput.readUTF());
   1070 
   1071       boolean hasString = objectInput.readBoolean();
   1072       if (hasString) {
   1073         setPreferredInternationalPrefix(objectInput.readUTF());
   1074       }
   1075 
   1076       hasString = objectInput.readBoolean();
   1077       if (hasString) {
   1078         setNationalPrefix(objectInput.readUTF());
   1079       }
   1080 
   1081       hasString = objectInput.readBoolean();
   1082       if (hasString) {
   1083         setPreferredExtnPrefix(objectInput.readUTF());
   1084       }
   1085 
   1086       hasString = objectInput.readBoolean();
   1087       if (hasString) {
   1088         setNationalPrefixForParsing(objectInput.readUTF());
   1089       }
   1090 
   1091       hasString = objectInput.readBoolean();
   1092       if (hasString) {
   1093         setNationalPrefixTransformRule(objectInput.readUTF());
   1094       }
   1095 
   1096       setSameMobileAndFixedLinePattern(objectInput.readBoolean());
   1097 
   1098       int nationalFormatSize = objectInput.readInt();
   1099       for (int i = 0; i < nationalFormatSize; i++) {
   1100         NumberFormat numFormat = new NumberFormat();
   1101         numFormat.readExternal(objectInput);
   1102         numberFormat_.add(numFormat);
   1103       }
   1104 
   1105       int intlNumberFormatSize = objectInput.readInt();
   1106       for (int i = 0; i < intlNumberFormatSize; i++) {
   1107         NumberFormat numFormat = new NumberFormat();
   1108         numFormat.readExternal(objectInput);
   1109         intlNumberFormat_.add(numFormat);
   1110       }
   1111 
   1112       setMainCountryForCode(objectInput.readBoolean());
   1113 
   1114       hasString = objectInput.readBoolean();
   1115       if (hasString) {
   1116         setLeadingDigits(objectInput.readUTF());
   1117       }
   1118 
   1119       setLeadingZeroPossible(objectInput.readBoolean());
   1120 
   1121       setMobileNumberPortableRegion(objectInput.readBoolean());
   1122     }
   1123   }
   1124 
   1125   public static class PhoneMetadataCollection implements Externalizable {
   1126     private static final long serialVersionUID = 1;
   1127     public PhoneMetadataCollection() {}
   1128 
   1129     /**
   1130      * Provides a dummy builder.
   1131      *
   1132      * @see NumberFormat.Builder
   1133      */
   1134     public static final class Builder extends PhoneMetadataCollection {
   1135       public PhoneMetadataCollection build() {
   1136         return this;
   1137       }
   1138     }
   1139     public static Builder newBuilder() {
   1140       return new Builder();
   1141     }
   1142 
   1143     // repeated PhoneMetadata metadata = 1;
   1144     private java.util.List<PhoneMetadata> metadata_ = new java.util.ArrayList<PhoneMetadata>();
   1145 
   1146     public java.util.List<PhoneMetadata> getMetadataList() {
   1147       return metadata_;
   1148     }
   1149     public int getMetadataCount() { return metadata_.size(); }
   1150 
   1151     public PhoneMetadataCollection addMetadata(PhoneMetadata value) {
   1152       if (value == null) {
   1153         throw new NullPointerException();
   1154       }
   1155       metadata_.add(value);
   1156       return this;
   1157     }
   1158 
   1159     public void writeExternal(ObjectOutput objectOutput) throws IOException {
   1160       int size = getMetadataCount();
   1161       objectOutput.writeInt(size);
   1162       for (int i = 0; i < size; i++) {
   1163         metadata_.get(i).writeExternal(objectOutput);
   1164       }
   1165     }
   1166 
   1167     public void readExternal(ObjectInput objectInput) throws IOException {
   1168       int size = objectInput.readInt();
   1169       for (int i = 0; i < size; i++) {
   1170         PhoneMetadata metadata = new PhoneMetadata();
   1171         metadata.readExternal(objectInput);
   1172         metadata_.add(metadata);
   1173       }
   1174     }
   1175 
   1176     public PhoneMetadataCollection clear() {
   1177       metadata_.clear();
   1178       return this;
   1179     }
   1180   }
   1181 }
   1182