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.getNationalPrefixOptionalWhenFormatting());
     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 [default = false];
    134     private boolean hasNationalPrefixOptionalWhenFormatting;
    135     private boolean nationalPrefixOptionalWhenFormatting_ = false;
    136     public boolean hasNationalPrefixOptionalWhenFormatting() {
    137       return hasNationalPrefixOptionalWhenFormatting; }
    138     public boolean getNationalPrefixOptionalWhenFormatting() {
    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         for (int i = 0; i < other.getPossibleLengthCount(); i++) {
    215           addPossibleLength(other.getPossibleLength(i));
    216         }
    217         for (int i = 0; i < other.getPossibleLengthLocalOnlyCount(); i++) {
    218           addPossibleLengthLocalOnly(other.getPossibleLengthLocalOnly(i));
    219         }
    220         if (other.hasExampleNumber()) {
    221           setExampleNumber(other.getExampleNumber());
    222         }
    223         return this;
    224       }
    225     }
    226 
    227     public static Builder newBuilder() {
    228       return new Builder();
    229     }
    230 
    231     // optional string national_number_pattern = 2;
    232     private boolean hasNationalNumberPattern;
    233     private String nationalNumberPattern_ = "";
    234     public boolean hasNationalNumberPattern() { return hasNationalNumberPattern; }
    235     public String getNationalNumberPattern() { return nationalNumberPattern_; }
    236     public PhoneNumberDesc setNationalNumberPattern(String value) {
    237       hasNationalNumberPattern = true;
    238       nationalNumberPattern_ = value;
    239       return this;
    240     }
    241     public PhoneNumberDesc clearNationalNumberPattern() {
    242       hasNationalNumberPattern = false;
    243       nationalNumberPattern_ = "";
    244       return this;
    245     }
    246 
    247     // repeated int32 possible_length = 9;
    248     private java.util.List<Integer> possibleLength_ = new java.util.ArrayList<Integer>();
    249     public java.util.List<Integer> getPossibleLengthList() {
    250       return possibleLength_;
    251     }
    252     public int getPossibleLengthCount() { return possibleLength_.size(); }
    253     public int getPossibleLength(int index) {
    254       return possibleLength_.get(index);
    255     }
    256     public PhoneNumberDesc addPossibleLength(int value) {
    257       possibleLength_.add(value);
    258       return this;
    259     }
    260     public PhoneNumberDesc clearPossibleLength() {
    261       possibleLength_.clear();
    262       return this;
    263     }
    264 
    265     // repeated int32 possible_length_local_only = 10;
    266     private java.util.List<Integer> possibleLengthLocalOnly_ = new java.util.ArrayList<Integer>();
    267     public java.util.List<Integer> getPossibleLengthLocalOnlyList() {
    268       return possibleLengthLocalOnly_;
    269     }
    270     public int getPossibleLengthLocalOnlyCount() { return possibleLengthLocalOnly_.size(); }
    271     public int getPossibleLengthLocalOnly(int index) {
    272       return possibleLengthLocalOnly_.get(index);
    273     }
    274     public PhoneNumberDesc addPossibleLengthLocalOnly(int value) {
    275       possibleLengthLocalOnly_.add(value);
    276       return this;
    277     }
    278     public PhoneNumberDesc clearPossibleLengthLocalOnly() {
    279       possibleLengthLocalOnly_.clear();
    280       return this;
    281     }
    282 
    283     // optional string example_number = 6;
    284     private boolean hasExampleNumber;
    285     private String exampleNumber_ = "";
    286     public boolean hasExampleNumber() { return hasExampleNumber; }
    287     public String getExampleNumber() { return exampleNumber_; }
    288     public PhoneNumberDesc setExampleNumber(String value) {
    289       hasExampleNumber = true;
    290       exampleNumber_ = value;
    291       return this;
    292     }
    293     public PhoneNumberDesc clearExampleNumber() {
    294       hasExampleNumber = false;
    295       exampleNumber_ = "";
    296       return this;
    297     }
    298 
    299     public boolean exactlySameAs(PhoneNumberDesc other) {
    300       return nationalNumberPattern_.equals(other.nationalNumberPattern_) &&
    301           possibleLength_.equals(other.possibleLength_) &&
    302           possibleLengthLocalOnly_.equals(other.possibleLengthLocalOnly_) &&
    303           exampleNumber_.equals(other.exampleNumber_);
    304     }
    305 
    306     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    307       objectOutput.writeBoolean(hasNationalNumberPattern);
    308       if (hasNationalNumberPattern) {
    309         objectOutput.writeUTF(nationalNumberPattern_);
    310       }
    311 
    312       int possibleLengthSize = getPossibleLengthCount();
    313       objectOutput.writeInt(possibleLengthSize);
    314       for (int i = 0; i < possibleLengthSize; i++) {
    315         objectOutput.writeInt(possibleLength_.get(i));
    316       }
    317 
    318       int possibleLengthLocalOnlySize = getPossibleLengthLocalOnlyCount();
    319       objectOutput.writeInt(possibleLengthLocalOnlySize);
    320       for (int i = 0; i < possibleLengthLocalOnlySize; i++) {
    321         objectOutput.writeInt(possibleLengthLocalOnly_.get(i));
    322       }
    323 
    324       objectOutput.writeBoolean(hasExampleNumber);
    325       if (hasExampleNumber) {
    326         objectOutput.writeUTF(exampleNumber_);
    327       }
    328     }
    329 
    330     public void readExternal(ObjectInput objectInput) throws IOException {
    331       if (objectInput.readBoolean()) {
    332         setNationalNumberPattern(objectInput.readUTF());
    333       }
    334 
    335       int possibleLengthSize = objectInput.readInt();
    336       for (int i = 0; i < possibleLengthSize; i++) {
    337         possibleLength_.add(objectInput.readInt());
    338       }
    339 
    340       int possibleLengthLocalOnlySize = objectInput.readInt();
    341       for (int i = 0; i < possibleLengthLocalOnlySize; i++) {
    342         possibleLengthLocalOnly_.add(objectInput.readInt());
    343       }
    344 
    345       if (objectInput.readBoolean()) {
    346         setExampleNumber(objectInput.readUTF());
    347       }
    348     }
    349   }
    350 
    351   public static class PhoneMetadata implements Externalizable {
    352     private static final long serialVersionUID = 1;
    353     public PhoneMetadata() {}
    354 
    355     /**
    356      * Provides a dummy builder.
    357      *
    358      * @see NumberFormat.Builder
    359      */
    360     public static final class Builder extends PhoneMetadata {
    361       public PhoneMetadata build() {
    362         return this;
    363       }
    364     }
    365     public static Builder newBuilder() {
    366       return new Builder();
    367     }
    368 
    369     // optional PhoneNumberDesc general_desc = 1;
    370     private boolean hasGeneralDesc;
    371     private PhoneNumberDesc generalDesc_ = null;
    372     public boolean hasGeneralDesc() { return hasGeneralDesc; }
    373     public PhoneNumberDesc getGeneralDesc() { return generalDesc_; }
    374     public PhoneMetadata setGeneralDesc(PhoneNumberDesc value) {
    375       if (value == null) {
    376         throw new NullPointerException();
    377       }
    378       hasGeneralDesc = true;
    379       generalDesc_ = value;
    380       return this;
    381     }
    382 
    383     // optional PhoneNumberDesc fixed_line = 2;
    384     private boolean hasFixedLine;
    385     private PhoneNumberDesc fixedLine_ = null;
    386     public boolean hasFixedLine() { return hasFixedLine; }
    387     public PhoneNumberDesc getFixedLine() { return fixedLine_; }
    388     public PhoneMetadata setFixedLine(PhoneNumberDesc value) {
    389       if (value == null) {
    390         throw new NullPointerException();
    391       }
    392       hasFixedLine = true;
    393       fixedLine_ = value;
    394       return this;
    395     }
    396 
    397     // optional PhoneNumberDesc mobile = 3;
    398     private boolean hasMobile;
    399     private PhoneNumberDesc mobile_ = null;
    400     public boolean hasMobile() { return hasMobile; }
    401     public PhoneNumberDesc getMobile() { return mobile_; }
    402     public PhoneMetadata setMobile(PhoneNumberDesc value) {
    403       if (value == null) {
    404         throw new NullPointerException();
    405       }
    406       hasMobile = true;
    407       mobile_ = value;
    408       return this;
    409     }
    410 
    411     // optional PhoneNumberDesc toll_free = 4;
    412     private boolean hasTollFree;
    413     private PhoneNumberDesc tollFree_ = null;
    414     public boolean hasTollFree() { return hasTollFree; }
    415     public PhoneNumberDesc getTollFree() { return tollFree_; }
    416     public PhoneMetadata setTollFree(PhoneNumberDesc value) {
    417       if (value == null) {
    418         throw new NullPointerException();
    419       }
    420       hasTollFree = true;
    421       tollFree_ = value;
    422       return this;
    423     }
    424 
    425     // optional PhoneNumberDesc premium_rate = 5;
    426     private boolean hasPremiumRate;
    427     private PhoneNumberDesc premiumRate_ = null;
    428     public boolean hasPremiumRate() { return hasPremiumRate; }
    429     public PhoneNumberDesc getPremiumRate() { return premiumRate_; }
    430     public PhoneMetadata setPremiumRate(PhoneNumberDesc value) {
    431       if (value == null) {
    432         throw new NullPointerException();
    433       }
    434       hasPremiumRate = true;
    435       premiumRate_ = value;
    436       return this;
    437     }
    438 
    439     // optional PhoneNumberDesc shared_cost = 6;
    440     private boolean hasSharedCost;
    441     private PhoneNumberDesc sharedCost_ = null;
    442     public boolean hasSharedCost() { return hasSharedCost; }
    443     public PhoneNumberDesc getSharedCost() { return sharedCost_; }
    444     public PhoneMetadata setSharedCost(PhoneNumberDesc value) {
    445       if (value == null) {
    446         throw new NullPointerException();
    447       }
    448       hasSharedCost = true;
    449       sharedCost_ = value;
    450       return this;
    451     }
    452 
    453     // optional PhoneNumberDesc personal_number = 7;
    454     private boolean hasPersonalNumber;
    455     private PhoneNumberDesc personalNumber_ = null;
    456     public boolean hasPersonalNumber() { return hasPersonalNumber; }
    457     public PhoneNumberDesc getPersonalNumber() { return personalNumber_; }
    458     public PhoneMetadata setPersonalNumber(PhoneNumberDesc value) {
    459       if (value == null) {
    460         throw new NullPointerException();
    461       }
    462       hasPersonalNumber = true;
    463       personalNumber_ = value;
    464       return this;
    465     }
    466 
    467     // optional PhoneNumberDesc voip = 8;
    468     private boolean hasVoip;
    469     private PhoneNumberDesc voip_ = null;
    470     public boolean hasVoip() { return hasVoip; }
    471     public PhoneNumberDesc getVoip() { return voip_; }
    472     public PhoneMetadata setVoip(PhoneNumberDesc value) {
    473       if (value == null) {
    474         throw new NullPointerException();
    475       }
    476       hasVoip = true;
    477       voip_ = value;
    478       return this;
    479     }
    480 
    481     // optional PhoneNumberDesc pager = 21;
    482     private boolean hasPager;
    483     private PhoneNumberDesc pager_ = null;
    484     public boolean hasPager() { return hasPager; }
    485     public PhoneNumberDesc getPager() { return pager_; }
    486     public PhoneMetadata setPager(PhoneNumberDesc value) {
    487       if (value == null) {
    488         throw new NullPointerException();
    489       }
    490       hasPager = true;
    491       pager_ = value;
    492       return this;
    493     }
    494 
    495     // optional PhoneNumberDesc uan = 25;
    496     private boolean hasUan;
    497     private PhoneNumberDesc uan_ = null;
    498     public boolean hasUan() { return hasUan; }
    499     public PhoneNumberDesc getUan() { return uan_; }
    500     public PhoneMetadata setUan(PhoneNumberDesc value) {
    501       if (value == null) {
    502         throw new NullPointerException();
    503       }
    504       hasUan = true;
    505       uan_ = value;
    506       return this;
    507     }
    508 
    509     // optional PhoneNumberDesc emergency = 27;
    510     private boolean hasEmergency;
    511     private PhoneNumberDesc emergency_ = null;
    512     public boolean hasEmergency() { return hasEmergency; }
    513     public PhoneNumberDesc getEmergency() { return emergency_; }
    514     public PhoneMetadata setEmergency(PhoneNumberDesc value) {
    515       if (value == null) {
    516         throw new NullPointerException();
    517       }
    518       hasEmergency = true;
    519       emergency_ = value;
    520       return this;
    521     }
    522 
    523     // optional PhoneNumberDesc voicemail = 28;
    524     private boolean hasVoicemail;
    525     private PhoneNumberDesc voicemail_ = null;
    526     public boolean hasVoicemail() { return hasVoicemail; }
    527     public PhoneNumberDesc getVoicemail() { return voicemail_; }
    528     public PhoneMetadata setVoicemail(PhoneNumberDesc value) {
    529       if (value == null) {
    530         throw new NullPointerException();
    531       }
    532       hasVoicemail = true;
    533       voicemail_ = value;
    534       return this;
    535     }
    536 
    537     // optional PhoneNumberDesc short_code = 29;
    538     private boolean hasShortCode;
    539     private PhoneNumberDesc shortCode_ = null;
    540     public boolean hasShortCode() { return hasShortCode; }
    541     public PhoneNumberDesc getShortCode() { return shortCode_; }
    542     public PhoneMetadata setShortCode(PhoneNumberDesc value) {
    543       if (value == null) {
    544         throw new NullPointerException();
    545       }
    546       hasShortCode = true;
    547       shortCode_ = value;
    548       return this;
    549     }
    550 
    551     // optional PhoneNumberDesc standard_rate = 30;
    552     private boolean hasStandardRate;
    553     private PhoneNumberDesc standardRate_ = null;
    554     public boolean hasStandardRate() { return hasStandardRate; }
    555     public PhoneNumberDesc getStandardRate() { return standardRate_; }
    556     public PhoneMetadata setStandardRate(PhoneNumberDesc value) {
    557       if (value == null) {
    558         throw new NullPointerException();
    559       }
    560       hasStandardRate = true;
    561       standardRate_ = value;
    562       return this;
    563     }
    564 
    565     // optional PhoneNumberDesc carrier_specific = 31;
    566     private boolean hasCarrierSpecific;
    567     private PhoneNumberDesc carrierSpecific_ = null;
    568     public boolean hasCarrierSpecific() { return hasCarrierSpecific; }
    569     public PhoneNumberDesc getCarrierSpecific() { return carrierSpecific_; }
    570     public PhoneMetadata setCarrierSpecific(PhoneNumberDesc value) {
    571       if (value == null) {
    572         throw new NullPointerException();
    573       }
    574       hasCarrierSpecific = true;
    575       carrierSpecific_ = value;
    576       return this;
    577     }
    578 
    579     // optional PhoneNumberDesc sms_services = 33;
    580     private boolean hasSmsServices;
    581     private PhoneNumberDesc smsServices_ = null;
    582     public boolean hasSmsServices() { return hasSmsServices; }
    583     public PhoneNumberDesc getSmsServices() { return smsServices_; }
    584     public PhoneMetadata setSmsServices(PhoneNumberDesc value) {
    585       if (value == null) {
    586         throw new NullPointerException();
    587       }
    588       hasSmsServices = true;
    589       smsServices_ = value;
    590       return this;
    591     }
    592 
    593     // optional PhoneNumberDesc noInternationalDialling = 24;
    594     private boolean hasNoInternationalDialling;
    595     private PhoneNumberDesc noInternationalDialling_ = null;
    596     public boolean hasNoInternationalDialling() { return hasNoInternationalDialling; }
    597     public PhoneNumberDesc getNoInternationalDialling() { return noInternationalDialling_; }
    598     public PhoneMetadata setNoInternationalDialling(PhoneNumberDesc value) {
    599       if (value == null) {
    600         throw new NullPointerException();
    601       }
    602       hasNoInternationalDialling = true;
    603       noInternationalDialling_ = value;
    604       return this;
    605     }
    606 
    607     // required string id = 9;
    608     private boolean hasId;
    609     private String id_ = "";
    610     public boolean hasId() { return hasId; }
    611     public String getId() { return id_; }
    612     public PhoneMetadata setId(String value) {
    613       hasId = true;
    614       id_ = value;
    615       return this;
    616     }
    617 
    618     // optional int32 country_code = 10;
    619     private boolean hasCountryCode;
    620     private int countryCode_ = 0;
    621     public boolean hasCountryCode() { return hasCountryCode; }
    622     public int getCountryCode() { return countryCode_; }
    623     public PhoneMetadata setCountryCode(int value) {
    624       hasCountryCode = true;
    625       countryCode_ = value;
    626       return this;
    627     }
    628 
    629     // optional string international_prefix = 11;
    630     private boolean hasInternationalPrefix;
    631     private String internationalPrefix_ = "";
    632     public boolean hasInternationalPrefix() { return hasInternationalPrefix; }
    633     public String getInternationalPrefix() { return internationalPrefix_; }
    634     public PhoneMetadata setInternationalPrefix(String value) {
    635       hasInternationalPrefix = true;
    636       internationalPrefix_ = value;
    637       return this;
    638     }
    639 
    640     // optional string preferred_international_prefix = 17;
    641     private boolean hasPreferredInternationalPrefix;
    642     private String preferredInternationalPrefix_ = "";
    643     public boolean hasPreferredInternationalPrefix() { return hasPreferredInternationalPrefix; }
    644     public String getPreferredInternationalPrefix() { return preferredInternationalPrefix_; }
    645     public PhoneMetadata setPreferredInternationalPrefix(String value) {
    646       hasPreferredInternationalPrefix = true;
    647       preferredInternationalPrefix_ = value;
    648       return this;
    649     }
    650     public PhoneMetadata clearPreferredInternationalPrefix() {
    651       hasPreferredInternationalPrefix = false;
    652       preferredInternationalPrefix_ = "";
    653       return this;
    654     }
    655 
    656     // optional string national_prefix = 12;
    657     private boolean hasNationalPrefix;
    658     private String nationalPrefix_ = "";
    659     public boolean hasNationalPrefix() { return hasNationalPrefix; }
    660     public String getNationalPrefix() { return nationalPrefix_; }
    661     public PhoneMetadata setNationalPrefix(String value) {
    662       hasNationalPrefix = true;
    663       nationalPrefix_ = value;
    664       return this;
    665     }
    666     public PhoneMetadata clearNationalPrefix() {
    667       hasNationalPrefix = false;
    668       nationalPrefix_ = "";
    669       return this;
    670     }
    671 
    672     // optional string preferred_extn_prefix = 13;
    673     private boolean hasPreferredExtnPrefix;
    674     private String preferredExtnPrefix_ = "";
    675     public boolean hasPreferredExtnPrefix() { return hasPreferredExtnPrefix; }
    676     public String getPreferredExtnPrefix() { return preferredExtnPrefix_; }
    677     public PhoneMetadata setPreferredExtnPrefix(String value) {
    678       hasPreferredExtnPrefix = true;
    679       preferredExtnPrefix_ = value;
    680       return this;
    681     }
    682     public PhoneMetadata clearPreferredExtnPrefix() {
    683       hasPreferredExtnPrefix = false;
    684       preferredExtnPrefix_ = "";
    685       return this;
    686     }
    687 
    688     // optional string national_prefix_for_parsing = 15;
    689     private boolean hasNationalPrefixForParsing;
    690     private String nationalPrefixForParsing_ = "";
    691     public boolean hasNationalPrefixForParsing() { return hasNationalPrefixForParsing; }
    692     public String getNationalPrefixForParsing() { return nationalPrefixForParsing_; }
    693     public PhoneMetadata setNationalPrefixForParsing(String value) {
    694       hasNationalPrefixForParsing = true;
    695       nationalPrefixForParsing_ = value;
    696       return this;
    697     }
    698 
    699     // optional string national_prefix_transform_rule = 16;
    700     private boolean hasNationalPrefixTransformRule;
    701     private String nationalPrefixTransformRule_ = "";
    702     public boolean hasNationalPrefixTransformRule() { return hasNationalPrefixTransformRule; }
    703     public String getNationalPrefixTransformRule() { return nationalPrefixTransformRule_; }
    704     public PhoneMetadata setNationalPrefixTransformRule(String value) {
    705       hasNationalPrefixTransformRule = true;
    706       nationalPrefixTransformRule_ = value;
    707       return this;
    708     }
    709     public PhoneMetadata clearNationalPrefixTransformRule() {
    710       hasNationalPrefixTransformRule = false;
    711       nationalPrefixTransformRule_ = "";
    712       return this;
    713     }
    714 
    715     // optional bool same_mobile_and_fixed_line_pattern = 18 [default = false];
    716     private boolean hasSameMobileAndFixedLinePattern;
    717     private boolean sameMobileAndFixedLinePattern_ = false;
    718     public boolean hasSameMobileAndFixedLinePattern() { return hasSameMobileAndFixedLinePattern; }
    719     public boolean getSameMobileAndFixedLinePattern() { return sameMobileAndFixedLinePattern_; }
    720     public PhoneMetadata setSameMobileAndFixedLinePattern(boolean value) {
    721       hasSameMobileAndFixedLinePattern = true;
    722       sameMobileAndFixedLinePattern_ = value;
    723       return this;
    724     }
    725     public PhoneMetadata clearSameMobileAndFixedLinePattern() {
    726       hasSameMobileAndFixedLinePattern = false;
    727       sameMobileAndFixedLinePattern_ = false;
    728       return this;
    729     }
    730 
    731     // repeated NumberFormat number_format = 19;
    732     private java.util.List<NumberFormat> numberFormat_ = new java.util.ArrayList<NumberFormat>();
    733     public java.util.List<NumberFormat> numberFormats() {
    734       return numberFormat_;
    735     }
    736     public int numberFormatSize() { return numberFormat_.size(); }
    737     public NumberFormat getNumberFormat(int index) {
    738       return numberFormat_.get(index);
    739     }
    740     public PhoneMetadata addNumberFormat(NumberFormat value) {
    741       if (value == null) {
    742         throw new NullPointerException();
    743       }
    744       numberFormat_.add(value);
    745       return this;
    746     }
    747 
    748     // repeated NumberFormat intl_number_format = 20;
    749     private java.util.List<NumberFormat> intlNumberFormat_ =
    750         new java.util.ArrayList<NumberFormat>();
    751     public java.util.List<NumberFormat> intlNumberFormats() {
    752       return intlNumberFormat_;
    753     }
    754     public int intlNumberFormatSize() { return intlNumberFormat_.size(); }
    755     public NumberFormat getIntlNumberFormat(int index) {
    756       return intlNumberFormat_.get(index);
    757     }
    758 
    759     public PhoneMetadata addIntlNumberFormat(NumberFormat value) {
    760       if (value == null) {
    761         throw new NullPointerException();
    762       }
    763       intlNumberFormat_.add(value);
    764       return this;
    765     }
    766     public PhoneMetadata clearIntlNumberFormat() {
    767       intlNumberFormat_.clear();
    768       return this;
    769     }
    770 
    771     // optional bool main_country_for_code = 22 [default = false];
    772     private boolean hasMainCountryForCode;
    773     private boolean mainCountryForCode_ = false;
    774     public boolean hasMainCountryForCode() { return hasMainCountryForCode; }
    775     public boolean isMainCountryForCode() { return mainCountryForCode_; }
    776     // Method that lets this class have the same interface as the one generated by Protocol Buffers
    777     // which is used by C++ build tools.
    778     public boolean getMainCountryForCode() { return mainCountryForCode_; }
    779     public PhoneMetadata setMainCountryForCode(boolean value) {
    780       hasMainCountryForCode = true;
    781       mainCountryForCode_ = value;
    782       return this;
    783     }
    784     public PhoneMetadata clearMainCountryForCode() {
    785       hasMainCountryForCode = false;
    786       mainCountryForCode_ = false;
    787       return this;
    788     }
    789 
    790     // optional string leading_digits = 23;
    791     private boolean hasLeadingDigits;
    792     private String leadingDigits_ = "";
    793     public boolean hasLeadingDigits() { return hasLeadingDigits; }
    794     public String getLeadingDigits() { return leadingDigits_; }
    795     public PhoneMetadata setLeadingDigits(String value) {
    796       hasLeadingDigits = true;
    797       leadingDigits_ = value;
    798       return this;
    799     }
    800 
    801     // optional bool leading_zero_possible = 26 [default = false];
    802     private boolean hasLeadingZeroPossible;
    803     private boolean leadingZeroPossible_ = false;
    804     public boolean hasLeadingZeroPossible() { return hasLeadingZeroPossible; }
    805     public boolean isLeadingZeroPossible() { return leadingZeroPossible_; }
    806     public PhoneMetadata setLeadingZeroPossible(boolean value) {
    807       hasLeadingZeroPossible = true;
    808       leadingZeroPossible_ = value;
    809       return this;
    810     }
    811     public PhoneMetadata clearLeadingZeroPossible() {
    812       hasLeadingZeroPossible = false;
    813       leadingZeroPossible_ = false;
    814       return this;
    815     }
    816 
    817     // optional bool mobile_number_portable_region = 32 [default = false];
    818     private boolean hasMobileNumberPortableRegion;
    819     private boolean mobileNumberPortableRegion_ = false;
    820     public boolean hasMobileNumberPortableRegion() { return hasMobileNumberPortableRegion; }
    821     public boolean isMobileNumberPortableRegion() { return mobileNumberPortableRegion_; }
    822     public PhoneMetadata setMobileNumberPortableRegion(boolean value) {
    823       hasMobileNumberPortableRegion = true;
    824       mobileNumberPortableRegion_ = value;
    825       return this;
    826     }
    827     public PhoneMetadata clearMobileNumberPortableRegion() {
    828       hasMobileNumberPortableRegion = false;
    829       mobileNumberPortableRegion_ = false;
    830       return this;
    831     }
    832 
    833     public void writeExternal(ObjectOutput objectOutput) throws IOException {
    834       objectOutput.writeBoolean(hasGeneralDesc);
    835       if (hasGeneralDesc) {
    836         generalDesc_.writeExternal(objectOutput);
    837       }
    838       objectOutput.writeBoolean(hasFixedLine);
    839       if (hasFixedLine) {
    840         fixedLine_.writeExternal(objectOutput);
    841       }
    842       objectOutput.writeBoolean(hasMobile);
    843       if (hasMobile) {
    844         mobile_.writeExternal(objectOutput);
    845       }
    846       objectOutput.writeBoolean(hasTollFree);
    847       if (hasTollFree) {
    848         tollFree_.writeExternal(objectOutput);
    849       }
    850       objectOutput.writeBoolean(hasPremiumRate);
    851       if (hasPremiumRate) {
    852         premiumRate_.writeExternal(objectOutput);
    853       }
    854       objectOutput.writeBoolean(hasSharedCost);
    855       if (hasSharedCost) {
    856         sharedCost_.writeExternal(objectOutput);
    857       }
    858       objectOutput.writeBoolean(hasPersonalNumber);
    859       if (hasPersonalNumber) {
    860         personalNumber_.writeExternal(objectOutput);
    861       }
    862       objectOutput.writeBoolean(hasVoip);
    863       if (hasVoip) {
    864         voip_.writeExternal(objectOutput);
    865       }
    866       objectOutput.writeBoolean(hasPager);
    867       if (hasPager) {
    868         pager_.writeExternal(objectOutput);
    869       }
    870       objectOutput.writeBoolean(hasUan);
    871       if (hasUan) {
    872         uan_.writeExternal(objectOutput);
    873       }
    874       objectOutput.writeBoolean(hasEmergency);
    875       if (hasEmergency) {
    876         emergency_.writeExternal(objectOutput);
    877       }
    878       objectOutput.writeBoolean(hasVoicemail);
    879       if (hasVoicemail) {
    880         voicemail_.writeExternal(objectOutput);
    881       }
    882       objectOutput.writeBoolean(hasShortCode);
    883       if (hasShortCode) {
    884         shortCode_.writeExternal(objectOutput);
    885       }
    886       objectOutput.writeBoolean(hasStandardRate);
    887       if (hasStandardRate) {
    888         standardRate_.writeExternal(objectOutput);
    889       }
    890       objectOutput.writeBoolean(hasCarrierSpecific);
    891       if (hasCarrierSpecific) {
    892         carrierSpecific_.writeExternal(objectOutput);
    893       }
    894       objectOutput.writeBoolean(hasSmsServices);
    895       if (hasSmsServices) {
    896         smsServices_.writeExternal(objectOutput);
    897       }
    898       objectOutput.writeBoolean(hasNoInternationalDialling);
    899       if (hasNoInternationalDialling) {
    900         noInternationalDialling_.writeExternal(objectOutput);
    901       }
    902 
    903       objectOutput.writeUTF(id_);
    904       objectOutput.writeInt(countryCode_);
    905       objectOutput.writeUTF(internationalPrefix_);
    906 
    907       objectOutput.writeBoolean(hasPreferredInternationalPrefix);
    908       if (hasPreferredInternationalPrefix) {
    909         objectOutput.writeUTF(preferredInternationalPrefix_);
    910       }
    911 
    912       objectOutput.writeBoolean(hasNationalPrefix);
    913       if (hasNationalPrefix) {
    914         objectOutput.writeUTF(nationalPrefix_);
    915       }
    916 
    917       objectOutput.writeBoolean(hasPreferredExtnPrefix);
    918       if (hasPreferredExtnPrefix) {
    919         objectOutput.writeUTF(preferredExtnPrefix_);
    920       }
    921 
    922       objectOutput.writeBoolean(hasNationalPrefixForParsing);
    923       if (hasNationalPrefixForParsing) {
    924         objectOutput.writeUTF(nationalPrefixForParsing_);
    925       }
    926 
    927       objectOutput.writeBoolean(hasNationalPrefixTransformRule);
    928       if (hasNationalPrefixTransformRule) {
    929         objectOutput.writeUTF(nationalPrefixTransformRule_);
    930       }
    931 
    932       objectOutput.writeBoolean(sameMobileAndFixedLinePattern_);
    933 
    934       int numberFormatSize = numberFormatSize();
    935       objectOutput.writeInt(numberFormatSize);
    936       for (int i = 0; i < numberFormatSize; i++) {
    937         numberFormat_.get(i).writeExternal(objectOutput);
    938       }
    939 
    940       int intlNumberFormatSize = intlNumberFormatSize();
    941       objectOutput.writeInt(intlNumberFormatSize);
    942       for (int i = 0; i < intlNumberFormatSize; i++) {
    943         intlNumberFormat_.get(i).writeExternal(objectOutput);
    944       }
    945 
    946       objectOutput.writeBoolean(mainCountryForCode_);
    947 
    948       objectOutput.writeBoolean(hasLeadingDigits);
    949       if (hasLeadingDigits) {
    950         objectOutput.writeUTF(leadingDigits_);
    951       }
    952 
    953       objectOutput.writeBoolean(leadingZeroPossible_);
    954 
    955       objectOutput.writeBoolean(mobileNumberPortableRegion_);
    956     }
    957 
    958     public void readExternal(ObjectInput objectInput) throws IOException {
    959       boolean hasDesc = objectInput.readBoolean();
    960       if (hasDesc) {
    961         PhoneNumberDesc desc = new PhoneNumberDesc();
    962         desc.readExternal(objectInput);
    963         setGeneralDesc(desc);
    964       }
    965       hasDesc = objectInput.readBoolean();
    966       if (hasDesc) {
    967         PhoneNumberDesc desc = new PhoneNumberDesc();
    968         desc.readExternal(objectInput);
    969         setFixedLine(desc);
    970       }
    971       hasDesc = objectInput.readBoolean();
    972       if (hasDesc) {
    973         PhoneNumberDesc desc = new PhoneNumberDesc();
    974         desc.readExternal(objectInput);
    975         setMobile(desc);
    976       }
    977       hasDesc = objectInput.readBoolean();
    978       if (hasDesc) {
    979         PhoneNumberDesc desc = new PhoneNumberDesc();
    980         desc.readExternal(objectInput);
    981         setTollFree(desc);
    982       }
    983       hasDesc = objectInput.readBoolean();
    984       if (hasDesc) {
    985         PhoneNumberDesc desc = new PhoneNumberDesc();
    986         desc.readExternal(objectInput);
    987         setPremiumRate(desc);
    988       }
    989       hasDesc = objectInput.readBoolean();
    990       if (hasDesc) {
    991         PhoneNumberDesc desc = new PhoneNumberDesc();
    992         desc.readExternal(objectInput);
    993         setSharedCost(desc);
    994       }
    995       hasDesc = objectInput.readBoolean();
    996       if (hasDesc) {
    997         PhoneNumberDesc desc = new PhoneNumberDesc();
    998         desc.readExternal(objectInput);
    999         setPersonalNumber(desc);
   1000       }
   1001       hasDesc = objectInput.readBoolean();
   1002       if (hasDesc) {
   1003         PhoneNumberDesc desc = new PhoneNumberDesc();
   1004         desc.readExternal(objectInput);
   1005         setVoip(desc);
   1006       }
   1007       hasDesc = objectInput.readBoolean();
   1008       if (hasDesc) {
   1009         PhoneNumberDesc desc = new PhoneNumberDesc();
   1010         desc.readExternal(objectInput);
   1011         setPager(desc);
   1012       }
   1013       hasDesc = objectInput.readBoolean();
   1014       if (hasDesc) {
   1015         PhoneNumberDesc desc = new PhoneNumberDesc();
   1016         desc.readExternal(objectInput);
   1017         setUan(desc);
   1018       }
   1019       hasDesc = objectInput.readBoolean();
   1020       if (hasDesc) {
   1021         PhoneNumberDesc desc = new PhoneNumberDesc();
   1022         desc.readExternal(objectInput);
   1023         setEmergency(desc);
   1024       }
   1025       hasDesc = objectInput.readBoolean();
   1026       if (hasDesc) {
   1027         PhoneNumberDesc desc = new PhoneNumberDesc();
   1028         desc.readExternal(objectInput);
   1029         setVoicemail(desc);
   1030       }
   1031       hasDesc = objectInput.readBoolean();
   1032       if (hasDesc) {
   1033         PhoneNumberDesc desc = new PhoneNumberDesc();
   1034         desc.readExternal(objectInput);
   1035         setShortCode(desc);
   1036       }
   1037       hasDesc = objectInput.readBoolean();
   1038       if (hasDesc) {
   1039         PhoneNumberDesc desc = new PhoneNumberDesc();
   1040         desc.readExternal(objectInput);
   1041         setStandardRate(desc);
   1042       }
   1043       hasDesc = objectInput.readBoolean();
   1044       if (hasDesc) {
   1045         PhoneNumberDesc desc = new PhoneNumberDesc();
   1046         desc.readExternal(objectInput);
   1047         setCarrierSpecific(desc);
   1048       }
   1049       hasDesc = objectInput.readBoolean();
   1050       if (hasDesc) {
   1051         PhoneNumberDesc desc = new PhoneNumberDesc();
   1052         desc.readExternal(objectInput);
   1053         setSmsServices(desc);
   1054       }
   1055       hasDesc = objectInput.readBoolean();
   1056       if (hasDesc) {
   1057         PhoneNumberDesc desc = new PhoneNumberDesc();
   1058         desc.readExternal(objectInput);
   1059         setNoInternationalDialling(desc);
   1060       }
   1061 
   1062       setId(objectInput.readUTF());
   1063       setCountryCode(objectInput.readInt());
   1064       setInternationalPrefix(objectInput.readUTF());
   1065 
   1066       boolean hasString = objectInput.readBoolean();
   1067       if (hasString) {
   1068         setPreferredInternationalPrefix(objectInput.readUTF());
   1069       }
   1070 
   1071       hasString = objectInput.readBoolean();
   1072       if (hasString) {
   1073         setNationalPrefix(objectInput.readUTF());
   1074       }
   1075 
   1076       hasString = objectInput.readBoolean();
   1077       if (hasString) {
   1078         setPreferredExtnPrefix(objectInput.readUTF());
   1079       }
   1080 
   1081       hasString = objectInput.readBoolean();
   1082       if (hasString) {
   1083         setNationalPrefixForParsing(objectInput.readUTF());
   1084       }
   1085 
   1086       hasString = objectInput.readBoolean();
   1087       if (hasString) {
   1088         setNationalPrefixTransformRule(objectInput.readUTF());
   1089       }
   1090 
   1091       setSameMobileAndFixedLinePattern(objectInput.readBoolean());
   1092 
   1093       int nationalFormatSize = objectInput.readInt();
   1094       for (int i = 0; i < nationalFormatSize; i++) {
   1095         NumberFormat numFormat = new NumberFormat();
   1096         numFormat.readExternal(objectInput);
   1097         numberFormat_.add(numFormat);
   1098       }
   1099 
   1100       int intlNumberFormatSize = objectInput.readInt();
   1101       for (int i = 0; i < intlNumberFormatSize; i++) {
   1102         NumberFormat numFormat = new NumberFormat();
   1103         numFormat.readExternal(objectInput);
   1104         intlNumberFormat_.add(numFormat);
   1105       }
   1106 
   1107       setMainCountryForCode(objectInput.readBoolean());
   1108 
   1109       hasString = objectInput.readBoolean();
   1110       if (hasString) {
   1111         setLeadingDigits(objectInput.readUTF());
   1112       }
   1113 
   1114       setLeadingZeroPossible(objectInput.readBoolean());
   1115 
   1116       setMobileNumberPortableRegion(objectInput.readBoolean());
   1117     }
   1118   }
   1119 
   1120   public static class PhoneMetadataCollection implements Externalizable {
   1121     private static final long serialVersionUID = 1;
   1122     public PhoneMetadataCollection() {}
   1123 
   1124     /**
   1125      * Provides a dummy builder.
   1126      *
   1127      * @see NumberFormat.Builder
   1128      */
   1129     public static final class Builder extends PhoneMetadataCollection {
   1130       public PhoneMetadataCollection build() {
   1131         return this;
   1132       }
   1133     }
   1134     public static Builder newBuilder() {
   1135       return new Builder();
   1136     }
   1137 
   1138     // repeated PhoneMetadata metadata = 1;
   1139     private java.util.List<PhoneMetadata> metadata_ = new java.util.ArrayList<PhoneMetadata>();
   1140 
   1141     public java.util.List<PhoneMetadata> getMetadataList() {
   1142       return metadata_;
   1143     }
   1144     public int getMetadataCount() { return metadata_.size(); }
   1145 
   1146     public PhoneMetadataCollection addMetadata(PhoneMetadata value) {
   1147       if (value == null) {
   1148         throw new NullPointerException();
   1149       }
   1150       metadata_.add(value);
   1151       return this;
   1152     }
   1153 
   1154     public void writeExternal(ObjectOutput objectOutput) throws IOException {
   1155       int size = getMetadataCount();
   1156       objectOutput.writeInt(size);
   1157       for (int i = 0; i < size; i++) {
   1158         metadata_.get(i).writeExternal(objectOutput);
   1159       }
   1160     }
   1161 
   1162     public void readExternal(ObjectInput objectInput) throws IOException {
   1163       int size = objectInput.readInt();
   1164       for (int i = 0; i < size; i++) {
   1165         PhoneMetadata metadata = new PhoneMetadata();
   1166         metadata.readExternal(objectInput);
   1167         metadata_.add(metadata);
   1168       }
   1169     }
   1170 
   1171     public PhoneMetadataCollection clear() {
   1172       metadata_.clear();
   1173       return this;
   1174     }
   1175   }
   1176 }
   1177