JAVA: Adding dummy builder to Phonemetadata.java. Patch contributed by philip.liard
authorjia.shao.peng <jia.shao.peng@ee073f10-1060-11df-b6a4-87a95322a99c>
Wed, 6 Apr 2011 08:32:58 +0000 (08:32 +0000)
committerjia.shao.peng <jia.shao.peng@ee073f10-1060-11df-b6a4-87a95322a99c>
Wed, 6 Apr 2011 08:32:58 +0000 (08:32 +0000)
git-svn-id: http://libphonenumber.googlecode.com/svn/trunk@158 ee073f10-1060-11df-b6a4-87a95322a99c

java/src/com/google/i18n/phonenumbers/Phonemetadata.java

index d8da296..f113d18 100644 (file)
@@ -29,10 +29,24 @@ import java.io.ObjectOutput;
 
 public final class Phonemetadata {
   private Phonemetadata() {}
-  public static final class NumberFormat implements Externalizable {
+  public static class NumberFormat implements Externalizable {
     private static final long serialVersionUID = 1;
     public NumberFormat() {}
 
+    /**
+     * Provides a dummy builder to 'emulate' the API of the code generated by the latest version of
+     * Protocol Buffers. This lets BuildMetadataFromXml class to build with both this hand created
+     * class and the one generated by the latest version of Protocol Buffers.
+     */
+    public static final class Builder extends NumberFormat {
+      public NumberFormat build() {
+        return this;
+      }
+    }
+    public static Builder newBuilder() {
+      return new Builder();
+    }
+
     // required string pattern = 1;
     private boolean hasPattern;
     private String pattern_ = "";
@@ -156,10 +170,24 @@ public final class Phonemetadata {
     }
   }
 
-  public static final class PhoneNumberDesc implements Externalizable {
+  public static class PhoneNumberDesc implements Externalizable {
     private static final long serialVersionUID = 1;
     public PhoneNumberDesc() {}
 
+    /**
+     * Provides a dummy builder.
+     *
+     * @see NumberFormat.Builder
+     */
+    public static final class Builder extends PhoneNumberDesc {
+      public PhoneNumberDesc build() {
+        return this;
+      }
+    }
+    public static Builder newBuilder() {
+      return new Builder();
+    }
+
     // optional string national_number_pattern = 2;
     private boolean hasNationalNumberPattern;
     private String nationalNumberPattern_ = "";
@@ -244,10 +272,24 @@ public final class Phonemetadata {
     }
   }
 
-  public static final class PhoneMetadata implements Externalizable {
+  public static class PhoneMetadata implements Externalizable {
     private static final long serialVersionUID = 1;
     public PhoneMetadata() {}
 
+    /**
+     * Provides a dummy builder.
+     *
+     * @see NumberFormat.Builder
+     */
+    public static final class Builder extends PhoneMetadata {
+      public PhoneMetadata build() {
+        return this;
+      }
+    }
+    public static Builder newBuilder() {
+      return new Builder();
+    }
+
     // required PhoneNumberDesc general_desc = 1;
     private boolean hasGeneralDesc;
     private PhoneNumberDesc generalDesc_ = null;
@@ -793,10 +835,24 @@ public final class Phonemetadata {
     }
   }
 
-  public static final class PhoneMetadataCollection implements Externalizable {
+  public static class PhoneMetadataCollection implements Externalizable {
     private static final long serialVersionUID = 1;
     public PhoneMetadataCollection() {}
 
+    /**
+     * Provides a dummy builder.
+     *
+     * @see NumberFormat.Builder
+     */
+    public static final class Builder extends PhoneMetadataCollection {
+      public PhoneMetadataCollection build() {
+        return this;
+      }
+    }
+    public static Builder newBuilder() {
+      return new Builder();
+    }
+
     // repeated PhoneMetadata metadata = 1;
     private java.util.List<PhoneMetadata> metadata_ = new java.util.ArrayList<PhoneMetadata>();