abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1200583 [3/5] - in /abdera/abdera2: activities/src/main/java/org/apache/abdera2/activities/client/ activities/src/main/java/org/apache/abdera2/activities/extra/ activities/src/main/java/org/apache/abdera2/activities/io/gson/ activities/src...
Date Thu, 10 Nov 2011 21:48:48 GMT
Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/AudioObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/AudioObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/AudioObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/AudioObject.java Thu Nov 10 21:48:45 2011
@@ -17,59 +17,70 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.MediaLink;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("audio")
 public class AudioObject 
   extends ASObject {
 
-  private static final long serialVersionUID = 3686825866815403406L;
   public static final String EMBEDCODE = "embedCode";
   public static final String STREAM = "stream";
   
-  public AudioObject() { }
+  public AudioObject(Map<String,Object> map) { 
+    super(map,AudioBuilder.class,AudioObject.class);
+  }
   
-  public AudioObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends AudioObject, M extends Builder<X,M>>AudioObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public String getEmbedCode() {
     return getProperty(EMBEDCODE);
   }
-  
-  public void setEmbedCode(String embedCode) {
-    setProperty(EMBEDCODE, embedCode);
-  }
-  
+
   public MediaLink getStream() {
     return getProperty(STREAM);
   }
-  
-  public void setStream(MediaLink stream) {
-    setProperty(STREAM, stream);
-  }
 
-  public static <T extends AudioObject>AudioObjectGenerator<T> makeAudio() {
-    return new AudioObjectGenerator<T>();
+  public static AudioBuilder makeAudio() {
+    return new AudioBuilder("audio");
+  }
+  
+  @Name("audio")
+  public static final class AudioBuilder extends Builder<AudioObject,AudioBuilder> {
+    public AudioBuilder() {
+      super(AudioObject.class,AudioBuilder.class);
+    }
+    public AudioBuilder(Map<String, Object> map) {
+      super(map, AudioObject.class,AudioBuilder.class);
+    }
+    public AudioBuilder(String objectType) {
+      super(objectType,AudioObject.class,AudioBuilder.class);
+    }
   }
   
   @SuppressWarnings("unchecked")
-  public static class AudioObjectGenerator<T extends AudioObject> extends ASObjectGenerator<T> {
-    public AudioObjectGenerator() {
-      super((Class<? extends T>) AudioObject.class);
-    }
-    public AudioObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends AudioObjectGenerator<T>>X embedCode(String code) {
-      item.setEmbedCode(code);
-      return (X)this;
-    }
-    public <X extends AudioObjectGenerator<T>>X stream(MediaLink stream) {
-      item.setStream(stream);
-      return (X)this;
+  public static abstract class Builder<X extends AudioObject,M extends Builder<X,M>>
+    extends ASObject.Builder<X,M> {
+    public Builder(Class<X> _class,Class<M> _builder) { 
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X> _class,Class<M> _builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X> _class,Class<M> _builder) {
+      super(map,_class,_builder);
+    }
+    public M embedCode(String code) {
+      set(EMBEDCODE,code);
+      return (M)this;
+    }
+    public M stream(MediaLink stream) {
+      set(STREAM,stream);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BadgeObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BadgeObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BadgeObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BadgeObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,37 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("badge")
 public class BadgeObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -3928700532413017490L;
   
-  public BadgeObject() {}
+  public static <T extends BadgeObject>Builder makeBadge() {
+    return new Builder("badge");
+  }
   
-  public BadgeObject(String displayName) {
-    setDisplayName(displayName);
+  @Name("badge")
+  public static class Builder extends ASObject.Builder<BadgeObject,Builder>{
+    public Builder() {
+      super(BadgeObject.class,Builder.class);
+    }
+    public Builder(String objectType) {
+      super(objectType,BadgeObject.class,Builder.class);
+    }
+    public Builder(Map<String,Object> map) {
+      super(map,BadgeObject.class,Builder.class);
+    }
   }
   
-  public static <T extends BadgeObject>BadgeObjectGenerator<T> makeBadge() {
-    return new BadgeObjectGenerator<T>();
+  public BadgeObject(Map<String,Object> map) {
+    super(map,Builder.class,BadgeObject.class);
   }
   
-  public static class BadgeObjectGenerator<T extends BadgeObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public BadgeObjectGenerator() {
-      super((Class<? extends T>) BadgeObject.class);
-    }
-    public BadgeObjectGenerator(Class<? extends T> _class) {
-      super(_class);
-    }
+  public <X extends ASObject, M extends ASObject.Builder<X,M>>BadgeObject(Map<String,Object> map, Class<M> _class, Class<X> _obj) {
+    super(map,_class,_obj);
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BinaryObject.java Thu Nov 10 21:48:45 2011
@@ -5,6 +5,7 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStream;
+import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.activation.MimeType;
@@ -34,103 +35,16 @@ import org.apache.commons.codec.binary.B
  * Applications need to be careful about which content types they 
  * will allow. 
  */
-@Name("binary")
-@Properties({
-  @Property(name="mimeType",to=MimeType.class)
-})
 public class BinaryObject extends FileObject {
   
-  private static final long serialVersionUID = 5120608845229587281L;
-
-  public BinaryObject() {
-    setMimeType("application/octet-stream");
+  public BinaryObject(Map<String,Object> map) {
+    super(map,BinaryBuilder.class,BinaryObject.class);
   }
   
-  public BinaryObject(String displayName) {
-    this();
-    setDisplayName(displayName);
+  public <X extends BinaryObject, M extends Builder<X,M>>BinaryObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
     
-  public void setData(DataHandler data, CompressionCodec... comps) throws IOException {
-    setData(data,(Hasher)null,comps);
-  }
-  
-  public void setData(byte[] data, Hasher hash, CompressionCodec... comps) throws IOException {
-    setData(new ByteArrayInputStream(data),hash,comps);
-  }
-  
-  /**
-   * Set the Content and the MimeType from the DatHandler. 
-   * This method defers to the setContent(InputStream) method
-   * by passing it the InputStream retrieved from the DataHandler.
-   * That means it currently blocks while reading, consuming, and
-   * encoding the InputStream. TODO: The better approach would be
-   * to simple store the DataHandler in the exts table directly
-   * and use a custom TypeAdapter for the BinaryObject to read and
-   * consume the DataHandler during the actual Serialization.
-   */
-  public void setData(DataHandler data,Hasher hash, CompressionCodec... comps) throws IOException {
-    setData(data.getInputStream(),hash,comps);
-    setMimeType(data.getContentType());
-  }
-  
-  public void setData(InputStream data) throws IOException {
-    setData(data,null);
-  }
-  
-  /**
-   * Set the Content as a Base64 Encoded string. Calling this 
-   * method will perform a blocking read that will consume the 
-   * InputStream and generate a Base64 Encoded String. 
-   * 
-   * If a Hasher class is provided, a hash digest for the 
-   * input data prior to encoding will be generated and 
-   * stored in a property value whose name is the value
-   * returned by Hasher.name(); e.g., HashHelper.Md5 will 
-   * add "md5":"{hex digest}" to the JSON object. 
-   * 
-   * The content may be optionally compressed prior to base64 
-   * encoding by passing in one or more CompressionCodecs. If 
-   * compression is used, a "compression" property will be added
-   * to the object whose value is a comma separated list of 
-   * the applied compression codecs in the order of application. 
-   * The getInputStream method will automatically search for the 
-   * "compression" property and attempt to automatically decompress
-   * the stream when reading.
-   * 
-   * This will also automatically set the "length" property equal 
-   * to the total number of uncompressed, unencoded octets.
-   */
-  public void setData(InputStream data, Hasher hash, CompressionCodec... comps) throws IOException {
-    ByteArrayOutputStream out = 
-      new ByteArrayOutputStream();
-    OutputStream bout = 
-      new Base64OutputStream(out,true,0,null);
-    if (comps.length > 0) {
-      bout = Compression.wrap(bout,comps);
-      String comp = Compression.describe(null, comps);
-      setProperty("compression",comp.substring(1,comp.length()-1));
-    }
-    
-    byte[] d = new byte[1024];
-    int r = -1, len = 0;
-    while((r = data.read(d)) > -1) { 
-      len += r;
-      if (hash != null)
-        hash.update(d, 0, r);
-      bout.write(d, 0, r);
-      bout.flush();
-    }
-    bout.close();
-    setProperty("length",len);
-    String c = new String(out.toByteArray(),"UTF-8");
-    super.setProperty("data",c);
-    if (hash != null)
-      setProperty(
-        hash.name(),
-        hash.get());
-  }
-  
   /**
    * Returns an InputStream that will decode the Base64 encoded 
    * content on the fly. The data is stored encoded in memory and
@@ -150,63 +64,175 @@ public class BinaryObject extends FileOb
     }
     return bin;
   }
+ 
+  public static BinaryBuilder makeBinary() {
+    return new BinaryBuilder("binary");
+  }
   
-  public void setData(byte[] data, CompressionCodec... comps) throws IOException {
-    setData(new ByteArrayInputStream(data),null,comps);
+  public static BinaryObject makeBinary(DataHandler data, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,comps).get();
   }
   
-  public void setData(byte[] data, int s, int e, CompressionCodec... comps) throws IOException {
-    setData(new ByteArrayInputStream(data,s,e),null,comps);
+  public static BinaryObject makeBinary(byte[] data, Hasher hash, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,hash,comps).get();
   }
   
-  public void setData(byte[] data, int s, int e, Hasher hash, CompressionCodec... comps) throws IOException {
-    setData(new ByteArrayInputStream(data,s,e),hash,comps);
+  public static BinaryObject makeBinary(DataHandler data,Hasher hash, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,hash,comps).get();
   }
- 
-  public static <T extends BinaryObject>BinaryObjectGenerator<T> makeBinary() {
-    return new BinaryObjectGenerator<T>();
+  
+  public static BinaryObject makeBinary(InputStream data) throws IOException {
+    return makeBinary().data(data).get();
+  }
+  
+  public static BinaryObject makeBinary(InputStream data, Hasher hash, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,hash,comps).get();
+  }
+
+  public static BinaryObject makeBinary(byte[] data, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,comps).get();
+  }
+  
+  public static BinaryObject makeBinary(byte[] data, int s, int e, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,s,e,comps).get();
+  }
+  
+  public static BinaryObject makeBinary(byte[] data, int s, int e, Hasher hash, CompressionCodec... comps) throws IOException {
+    return makeBinary().data(data,s,e,hash,comps).get();
+  }
+  
+  
+  @Name("binary")
+  @Properties({
+    @Property(name="mimeType",to=MimeType.class)
+  })
+  public static final class BinaryBuilder extends Builder<BinaryObject,BinaryBuilder> {
+    public BinaryBuilder() {
+      super(BinaryObject.class,BinaryBuilder.class);
+    }
+    public BinaryBuilder(Map<String, Object> map) {
+      super(map, BinaryObject.class,BinaryBuilder.class);
+    }
+    public BinaryBuilder(String objectType) {
+      super(objectType, BinaryObject.class,BinaryBuilder.class);
+    }
   }
   
   @SuppressWarnings("unchecked")
-  public static class BinaryObjectGenerator<T extends BinaryObject> extends FileObjectGenerator<T> {
-    public BinaryObjectGenerator() {
-      super((Class<T>) BinaryObject.class);
+  public static class Builder<X extends BinaryObject,M extends Builder<X,M>> 
+    extends FileObject.Builder<X,M> {
+    
+    boolean a;
+    
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
     }
-    public BinaryObjectGenerator(Class<T> _class) {
-      super(_class);
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(InputStream in) throws IOException {
-      item.setData(in);
-      return (X)this;
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(InputStream in, Hasher hasher, CompressionCodec... codecs) throws IOException {
-      item.setData(in,hasher,codecs);
-      return (X)this;
+    public M mimeType(MimeType mimeType) {
+      a = true;
+      return super.mimeType(mimeType);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(DataHandler in, CompressionCodec... codecs) throws IOException {
-      item.setData(in,codecs);
-      return (X)this;
+    
+    public M data(DataHandler data, CompressionCodec... comps) throws IOException {
+      return data(data,(Hasher)null,comps);
+    }
+    
+    public M data(byte[] data, Hasher hash, CompressionCodec... comps) throws IOException {
+      return data(new ByteArrayInputStream(data),hash,comps);
+    }
+    
+    /**
+     * Set the Content and the MimeType from the DatHandler. 
+     * This method defers to the setContent(InputStream) method
+     * by passing it the InputStream retrieved from the DataHandler.
+     * That means it currently blocks while reading, consuming, and
+     * encoding the InputStream. TODO: The better approach would be
+     * to simple store the DataHandler in the exts table directly
+     * and use a custom TypeAdapter for the BinaryObject to read and
+     * consume the DataHandler during the actual Serialization.
+     */
+    public M data(DataHandler data,Hasher hash, CompressionCodec... comps) throws IOException {
+      data(data.getInputStream(),hash,comps);
+      if (!a) mimeType(data.getContentType());
+      return (M)this;
+    }
+    
+    public M data(InputStream data) throws IOException {
+      return data(data,null);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(DataHandler in, Hasher hasher, CompressionCodec... codecs) throws IOException {
-      item.setData(in,hasher,codecs);
-      return (X)this;
+    
+    /**
+     * Set the Content as a Base64 Encoded string. Calling this 
+     * method will perform a blocking read that will consume the 
+     * InputStream and generate a Base64 Encoded String. 
+     * 
+     * If a Hasher class is provided, a hash digest for the 
+     * input data prior to encoding will be generated and 
+     * stored in a property value whose name is the value
+     * returned by Hasher.name(); e.g., HashHelper.Md5 will 
+     * add "md5":"{hex digest}" to the JSON object. 
+     * 
+     * The content may be optionally compressed prior to base64 
+     * encoding by passing in one or more CompressionCodecs. If 
+     * compression is used, a "compression" property will be added
+     * to the object whose value is a comma separated list of 
+     * the applied compression codecs in the order of application. 
+     * The getInputStream method will automatically search for the 
+     * "compression" property and attempt to automatically decompress
+     * the stream when reading.
+     * 
+     * This will also automatically set the "length" property equal 
+     * to the total number of uncompressed, unencoded octets.
+     */
+    public M data(InputStream data, Hasher hash, CompressionCodec... comps) throws IOException {
+      ByteArrayOutputStream out = 
+        new ByteArrayOutputStream();
+      OutputStream bout = 
+        new Base64OutputStream(out,true,0,null);
+      if (comps.length > 0) {
+        bout = Compression.wrap(bout,comps);
+        String comp = Compression.describe(null, comps);
+        set("compression",comp.substring(1,comp.length()-1));
+      }
+      byte[] d = new byte[1024];
+      int r = -1, len = 0;
+      while((r = data.read(d)) > -1) { 
+        len += r;
+        if (hash != null)
+          hash.update(d, 0, r);
+        bout.write(d, 0, r);
+        bout.flush();
+      }
+      bout.close();
+      set("length",len);
+      String c = new String(out.toByteArray(),"UTF-8");
+      set("data",c);
+      if (hash != null)
+        set(
+          hash.name(),
+          hash.get());
+      return (M)this;
     }
-    public <X extends BinaryObjectGenerator<T>>X data(byte[] in, CompressionCodec... codecs) throws IOException {
-      item.setData(in,codecs);
-      return (X)this;
+
+    public M data(byte[] data, CompressionCodec... comps) throws IOException {
+      return data(new ByteArrayInputStream(data),null,comps);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(byte[] in, Hasher hasher, CompressionCodec... codecs) throws IOException {
-      item.setData(in,hasher,codecs);
-      return (X)this;
+    
+    public M data(byte[] data, int s, int e, CompressionCodec... comps) throws IOException {
+      return data(new ByteArrayInputStream(data,s,e),null,comps);
     }
     
-    public <X extends BinaryObjectGenerator<T>>X data(byte[] in, int s, int e, CompressionCodec... codecs) throws IOException {
-      item.setData(in,s,e,codecs);
-      return (X)this;
+    public M data(byte[] data, int s, int e, Hasher hash, CompressionCodec... comps) throws IOException {
+      return data(new ByteArrayInputStream(data,s,e),hash,comps);
     }
-    public <X extends BinaryObjectGenerator<T>>X data(byte[] in, int s, int e, Hasher hasher, CompressionCodec... codecs) throws IOException {
-      item.setData(in,s,e,hasher,codecs);
-      return (X)this;
+    
+    public void preGet() {
+      if (!a)  mimeType("application/octet-stream");
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookObject.java Thu Nov 10 21:48:45 2011
@@ -1,5 +1,7 @@
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
@@ -7,98 +9,94 @@ import org.apache.abdera2.common.anno.Na
  * A simple "objectType":"book" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("book")
+@SuppressWarnings("unchecked")
 public class BookObject extends CreativeWork {
 
-  private static final long serialVersionUID = -178336535850006357L;
 
-  public BookObject() {}
+  public BookObject(Map<String,Object> map) {
+    super(map,BookBuilder.class,BookObject.class);
+  }
   
-  public BookObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends BookObject, M extends Builder<X,M>>BookObject(Map<String,Object> map, Class<M> _class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
-  @SuppressWarnings("unchecked")
   public <T extends ASObject>T getFormat() {
     return (T)getProperty("format");
   }
   
-  public void setFormat(ASObject format) {
-    setProperty("format", format);
-  }
-  
   public String getEdition() {
     return getProperty("edition");
   }
   
-  public void setEdition(String edition) {
-    setProperty("edition", edition);
-  }
-  
   public String getIsbn10() {
     return getProperty("isbn10");
   }
   
-  public void setIsbn10(String isbn) {
-    setProperty("isbn10", isbn);
-  }
-  
   public String getIsbn13() {
     return getProperty("isbn13");
   }
   
-  public void setIsbn13(String isbn) {
-    setProperty("isbn13", isbn);
-  }
-  
   public int getPageCount() {
-    return (Integer)getProperty("pageCount");
+    return getPropertyInt("pageCount");
   }
   
-  public void setPageCount(int pageCount) {
-    setProperty("pageCount", pageCount);
-  }
-
-  @SuppressWarnings("unchecked")
   public <T extends ASObject>T getIllustrator() {
     return (T)getProperty("illustrator");
   }
   
-  public void setIllustrator(ASObject illustrator) {
-    setProperty("illustrator", illustrator);
+  public static BookBuilder makeBook() {
+    return new BookBuilder("book");
   }
- 
-  public static <T extends BookObject>BookObjectGenerator<T> makeBook() {
-    return new BookObjectGenerator<T>();
+  
+  @Name("book")
+  public static final class BookBuilder extends Builder<BookObject,BookBuilder> {
+    public BookBuilder() {
+      super(BookObject.class,BookBuilder.class);
+    }
+    public BookBuilder(Map<String, Object> map) {
+      super(map, BookObject.class,BookBuilder.class);
+    }
+    public BookBuilder(String objectType) {
+      super(objectType, BookObject.class,BookBuilder.class);
+    }
   }
   
-  @SuppressWarnings("unchecked")
-  public static class BookObjectGenerator<T extends BookObject> extends CreativeWorkGenerator<T> {
-    public BookObjectGenerator() {
-      super((Class<T>) BookObject.class);
+  public abstract static class Builder<X extends BookObject,M extends Builder<X,M>> 
+    extends CreativeWork.Builder<X,M> {
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
     }
-    public BookObjectGenerator(Class<T> _class) {
-      super(_class);
+    protected Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends BookObjectGenerator<T>>X edition(String val) {
-      item.setEdition(val);
-      return (X)this;
+    public M edition(String val) {
+      set("edition",val);
+      return (M)this;
     }
-    public <X extends BookObjectGenerator<T>>X format(ASObject obj) {
-      item.setFormat(obj);
-      return (X)this;
+    public M format(ASObject obj) {
+      set("format",obj);
+      return (M)this;
     }
-    public <X extends BookObjectGenerator<T>>X illustrator(ASObject obj) {
-      item.setIllustrator(obj);
-      return (X)this;
+    public M illustrator(ASObject obj) {
+      set("illustrator",obj);
+      return (M)this;
     }
-    public <X extends BookObjectGenerator<T>>X isbn10(String val) {
-      item.setIsbn10(val);
-      return (X)this;
+    public M isbn10(String val) {
+      set("isbn10",val);
+      return (M)this;
     }
-    public <X extends BookObjectGenerator<T>>X pageCount(int count) {
-      item.setPageCount(count);
-      return (X)this;
+    public M isbn13(String val) {
+      set("isbn13",val);
+      return (M)this;
     }
+    public M pageCount(int count) {
+      set("pageCount",count);
+      return (M)this;
+    }
+
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookmarkObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookmarkObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookmarkObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/BookmarkObject.java Thu Nov 10 21:48:45 2011
@@ -17,50 +17,73 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 import org.apache.abdera2.common.iri.IRI;
 
-@Name("bookmark")
 public class BookmarkObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -2753772783838463022L;
   public static final String TARGETURL = "targetUrl";
   
-  public BookmarkObject() {}
-  
-  public BookmarkObject(String displayName) {
-    setDisplayName(displayName);
+  public BookmarkObject(Map<String,Object> map) {
+    super(map,BookmarkBuilder.class,BookmarkObject.class);
   }
   
+  public <X extends BookmarkObject, M extends Builder<X,M>>BookmarkObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
+  }
+
   public String getTargetUrl() {
     return getProperty(TARGETURL);
   }
   
-  public void setTargetUrl(String targetUrl) {
-    setProperty(TARGETURL, targetUrl);
+  public static BookmarkBuilder makeBookmark() {
+    return new BookmarkBuilder("bookmark");
   }
 
-  public static <T extends BookmarkObject>BookmarkObjectGenerator<T> makeBookmark() {
-    return new BookmarkObjectGenerator<T>();
+  public static BookmarkBuilder makeBookmark(String targetUrl) {
+    return makeBookmark().targetUrl(targetUrl);
+  }
+  
+  public static BookmarkBuilder makeBookmark(IRI targetUrl) {
+    return makeBookmark().targetUrl(targetUrl);
+  }
+  
+  @Name("bookmark")
+  public static final class BookmarkBuilder 
+    extends Builder<BookmarkObject,BookmarkBuilder> {
+    public BookmarkBuilder() {
+      super(BookmarkObject.class,BookmarkBuilder.class);
+    }
+    public BookmarkBuilder(Map<String, Object> map) {
+      super(map, BookmarkObject.class,BookmarkBuilder.class);
+    }
+    public BookmarkBuilder(String objectType) {
+      super(objectType, BookmarkObject.class,BookmarkBuilder.class);
+    }
   }
   
   @SuppressWarnings("unchecked")
-  public static class BookmarkObjectGenerator<T extends BookmarkObject> extends ASObjectGenerator<T> {
-    public BookmarkObjectGenerator() {
-      super((Class<? extends T>) BookmarkObject.class);
-    }
-    public BookmarkObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends BookmarkObjectGenerator<T>>X targetUrl(String uri) {
-      item.setTargetUrl(uri);
-      return (X)this;
-    }
-    public <X extends BookmarkObjectGenerator<T>>X targetUrl(IRI uri) {
-      item.setTargetUrl(uri != null ? uri.toString() : null);
-      return (X)this;
+  public static abstract class Builder<X extends BookmarkObject, M extends Builder<X,M>> 
+    extends ASObject.Builder<X,M> {
+    public Builder(Class<X> _class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X> _class,Class<M>_builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X> _class,Class<M>_builder) {
+      super(map,_class,_builder);
+    }
+    public M targetUrl(String uri) {
+      return targetUrl(new IRI(uri));
     }
+    public M targetUrl(IRI uri) {
+      set(TARGETURL,uri);
+      return (M)this;
+    }    
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CommentObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CommentObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CommentObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CommentObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,37 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("comment")
 public class CommentObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -7911420073285087386L;
-  
-  public CommentObject() {}
   
-  public CommentObject(String displayName) {
-    setDisplayName(displayName);
-  }
-
-  public static <T extends CommentObject>CommentObjectGenerator<T> makeComment() {
-    return new CommentObjectGenerator<T>();
+  public static <T extends CommentObject>Builder makeComment() {
+    return new Builder("comment");
   }
   
-  public static class CommentObjectGenerator<T extends CommentObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public CommentObjectGenerator() {
-      super((Class<? extends T>) CommentObject.class);
+  @Name("comment")
+  public static class Builder extends ASObject.Builder<CommentObject,Builder> {
+    public Builder() {
+      super(CommentObject.class,Builder.class);
     }
-    public CommentObjectGenerator(Class<? extends T> _class) {
-      super(_class);
+    public Builder(String objectType) {
+      super(objectType,CommentObject.class,Builder.class);
     }
+    protected Builder(Map<String,Object> map) {
+      super(map,CommentObject.class,Builder.class);
+    }    
+  }
+  
+  public CommentObject(Map<String,Object> map) {
+    super(map,Builder.class,CommentObject.class);
+  }
+ 
+  public <X extends CommentObject, M extends ASObject.Builder<X,M>>CommentObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/CreativeWork.java Thu Nov 10 21:48:45 2011
@@ -1,5 +1,7 @@
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 
 /**
@@ -8,89 +10,69 @@ import org.apache.abdera2.activities.mod
 @SuppressWarnings("unchecked")
 public abstract class CreativeWork extends ASObject {
 
-  private static final long serialVersionUID = -178336535850006357L;
 
-  public CreativeWork() {}
-  
-  public CreativeWork(String displayName) {
-    setDisplayName(displayName);
+  protected <X extends CreativeWork, M extends Builder<X,M>>CreativeWork(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public <T extends ASObject>T getAbout() {
     return (T)getProperty("about");
   }
   
-  public void setAbout(ASObject about) {
-    setProperty("about", about);
-  }
-  
   public <T extends ASObject>T getGenre() {
     return (T)getProperty("genre");
   }
   
-  public void setGenre(ASObject genre) {
-    setProperty("genre", genre);
-  }
-  
   public <T extends ASObject>T getPublisher() {
     return (T)getProperty("publisher");
   }
   
-  public void setPublisher(ASObject publisher) {
-    setProperty("publisher", publisher);
-  }
-  
   public <T extends ASObject>T getProvider() {
     return (T)getProperty("provider");
   }
   
-  public void setProvider(ASObject provider) {
-    setProperty("provider", provider);
-  }
-  
   public <T extends ASObject>T getContributor() {
     return (T)getProperty("contributor");
   }
   
-  public void setContributor(ASObject contributor) {
-    setProperty("contributor", contributor);
-  }
-  
   public <T extends ASObject>T getEditor() {
     return (T)getProperty("editor");
   }
   
-  public void setEditor(ASObject editor) {
-    setProperty("editor", editor);
-  }
-  
-  public static abstract class CreativeWorkGenerator<T extends CreativeWork> extends ASObjectGenerator<T> {
-    protected CreativeWorkGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends CreativeWorkGenerator<T>>X about(ASObject object) {
-      item.setAbout(object);
-      return (X)this;
-    }
-    public <X extends CreativeWorkGenerator<T>>X contributor(ASObject object) {
-      item.setContributor(object);
-      return (X)this;
-    }
-    public <X extends CreativeWorkGenerator<T>>X editor(ASObject object) {
-      item.setEditor(object);
-      return (X)this;
-    }
-    public <X extends CreativeWorkGenerator<T>>X genre(ASObject object) {
-      item.setGenre(object);
-      return (X)this;
-    }
-    public <X extends CreativeWorkGenerator<T>>X provider(ASObject object) {
-      item.setProvider(object);
-      return (X)this;
-    }
-    public <X extends CreativeWorkGenerator<T>>X publisher(ASObject object) {
-      item.setPublisher(object);
-      return (X)this;
+  public static abstract class Builder<X extends CreativeWork, M extends Builder<X,M>> 
+    extends ASObject.Builder<X,M> {
+    protected Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    protected Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
+    }
+    protected Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
+    }
+    public M about(ASObject object) {
+      set("about",object);
+      return (M)this;
+    }
+    public M contributor(ASObject object) {
+      set("contributor",object);
+      return (M)this;
+    }
+    public M editor(ASObject object) {
+      set("editor",object);
+      return (M)this;
+    }
+    public M genre(ASObject object) {
+      set("genre",object);
+      return (M)this;
+    }
+    public M provider(ASObject object) {
+      set("provider",object);
+      return (M)this;
+    }
+    public M publisher(ASObject object) {
+      set("publisher",object);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EmbeddedExperience.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EmbeddedExperience.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EmbeddedExperience.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EmbeddedExperience.java Thu Nov 10 21:48:45 2011
@@ -3,10 +3,10 @@ package org.apache.abdera2.activities.mo
 import java.util.Map;
 
 import org.apache.abdera2.activities.model.ASBase;
-import org.apache.abdera2.activities.model.ASObject;
-import org.apache.abdera2.activities.model.Generator;
 import org.apache.abdera2.common.iri.IRI;
 
+import com.google.common.collect.ImmutableMap;
+
 /**
  * Represents an Embedded Experience data structure. Embedded Experiences
  * were introduced to Activity Streams through the OpenSocial 2.0 specification.
@@ -15,110 +15,169 @@ import org.apache.abdera2.common.iri.IRI
  * Gadget specification with an Activity Stream object that can be rendered 
  * in-line when the activity data is displayed within an OpenSocial container.
  */
-public class EmbeddedExperience 
+public final class EmbeddedExperience 
   extends ASBase {
-
-  private static final long serialVersionUID = -4311572934016006379L;
-
-  public EmbeddedExperience() {}
-  
-  public IRI getUrl() {
-    return getProperty("url");
-  }
   
-  public void setUrl(IRI iri) {
-    setProperty("url", iri);
+  public EmbeddedExperience(Map<String,Object> map) {
+    super(map,Builder.class,EmbeddedExperience.class);
   }
   
-  public void setUrl(String iri) {
-    setUrl(new IRI(iri));
+  public IRI getUrl() {
+    return getProperty("url");
   }
   
   public IRI getGadget() {
     return getProperty("gadget");
   }
   
-  public void setGadget(IRI iri) {
-    setProperty("gadget", iri);
-  }
-  
-  public void setGadget(String iri) {
-    setGadget(new IRI(iri));
-  }
-  
   public ASBase getContext() {
     return getProperty("context");
   }
   
-  public void setContext(ASBase context) {
-    setProperty("context", context);
-  }
-  
-  public void setContext(Map<String,Object> context) {
-    setProperty("context", context);
-  }
-  
   public IRI getPreviewImage() {
     return getProperty("previewImage");
   }
   
-  public void setPreviewImage(IRI iri) {
-    setProperty("previewImage", iri);
-  }
-  
-  public void setPreviewImage(String iri) {
-    setGadget(new IRI(iri));
+  public static Builder makeEmbeddedExperience() {
+    return new Builder();
   }
   
-  public static EmbeddedExperienceGenerator makeEmbeddedExperience() {
-    return new EmbeddedExperienceGenerator();
+  public static EmbeddedExperience makeGadgetEmbeddedExperience(
+    String url, 
+    ASBase context, 
+    String preview) {
+    return makeEmbeddedExperience()
+      .gadget(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeGadgetEmbeddedExperience(
+    IRI url, 
+    ASBase context, 
+    IRI preview) {
+    return makeEmbeddedExperience()
+      .gadget(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeGadgetEmbeddedExperience(
+    String url, 
+    Map<String,Object> context, 
+    String preview) {
+    return makeEmbeddedExperience()
+      .gadget(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeGadgetEmbeddedExperience(
+    IRI url, 
+    Map<String,Object> context, 
+    IRI preview) {
+    return makeEmbeddedExperience()
+      .gadget(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  
+  public static EmbeddedExperience makeUrlEmbeddedExperience(
+    String url, 
+    ASBase context, 
+    String preview) {
+    return makeEmbeddedExperience()
+      .url(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeUrlEmbeddedExperience(
+    IRI url, 
+    ASBase context, 
+    IRI preview) {
+    return makeEmbeddedExperience()
+      .url(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeUrlEmbeddedExperience(
+    String url, 
+    Map<String,Object> context, 
+    String preview) {
+    return makeEmbeddedExperience()
+      .url(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
+  }
+  
+  public static EmbeddedExperience makeUrlEmbeddedExperience(
+    IRI url, 
+    Map<String,Object> context, 
+    IRI preview) {
+    return makeEmbeddedExperience()
+      .url(url)
+      .context(context)
+      .previewImage(preview)
+      .get();
   }
   
-  public static class EmbeddedExperienceGenerator 
-    extends Generator<EmbeddedExperience> {
+  public final static class Builder 
+    extends ASBase.Builder<EmbeddedExperience,Builder> {
 
-    public EmbeddedExperienceGenerator() {
-      super(EmbeddedExperience.class);
+    public Builder() {
+      super(EmbeddedExperience.class,Builder.class);
     }
     
-    public EmbeddedExperienceGenerator context(ASObject object) {
-      item.setContext(object);
+    protected Builder(Map<String,Object> map) {
+      super(map,EmbeddedExperience.class,Builder.class);
+    }
+
+    public Builder context(ASBase object) {
+      set("context", object);
       return this;
     }
     
-    public EmbeddedExperienceGenerator context(Map<String,Object> map) {
-      item.setContext(map);
+    public Builder context(Map<String,Object> map) {
+      set("context", ImmutableMap.copyOf(map));
       return this;
     }
     
-    public EmbeddedExperienceGenerator gadget(IRI iri) {
-      item.setGadget(iri);
+    public Builder gadget(IRI iri) {
+      set("gadget",iri);
       return this;
     }
     
-    public EmbeddedExperienceGenerator gadget(String iri) {
-      item.setGadget(iri);
-      return this;
+    public Builder gadget(String iri) {
+      return gadget(iri);
     }
     
-    public EmbeddedExperienceGenerator previewImage(IRI iri) {
-      item.setPreviewImage(iri);
+    public Builder previewImage(IRI iri) {
+      set("previewImage",iri);
       return this;
     }
     
-    public EmbeddedExperienceGenerator previewImage(String iri) {
-      item.setPreviewImage(iri);
-      return this;
+    public Builder previewImage(String iri) {
+      return previewImage(new IRI(iri));
     }
     
-    public EmbeddedExperienceGenerator url(IRI iri) {
-      item.setUrl(iri);
+    public Builder url(IRI iri) {
+      set("url",iri);
       return this;
     }
     
-    public EmbeddedExperienceGenerator url(String uri) {
-      item.setUrl(uri);
-      return this;
+    public Builder url(String uri) {
+      return url(new IRI(uri));
     }
+    
   }
 }

Copied: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ErrorObject.java (from r1187164, abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java)
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ErrorObject.java?p2=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ErrorObject.java&p1=abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java&r1=1187164&r2=1200583&rev=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/protocol/ErrorObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ErrorObject.java Thu Nov 10 21:48:45 2011
@@ -15,50 +15,58 @@
  * copyright in this work, please see the NOTICE file in the top level
  * directory of this distribution.
  */
-package org.apache.abdera2.activities.protocol;
+package org.apache.abdera2.activities.model.objects;
+
+import java.util.Map;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;
 import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.common.anno.Name;
 
-@Properties(
-@Property(name="code",to=Integer.class)
-)
-public class ErrorObject extends ASObject {
-  private static final long serialVersionUID = 2361855511692036786L;
+public final class ErrorObject extends ASObject {
   public static final String TYPE = "error";
-  public ErrorObject() {
-    super(TYPE);
+  public ErrorObject(Map<String,Object> map) {
+    super(map,Builder.class,ErrorObject.class);
   }  
-  public ErrorObject(String displayName) {
-    super(TYPE);
-    setDisplayName(displayName);
-  }
-  public String getObjectType() {
-    return TYPE;
-  }
+
   public int getCode() {
-    return (Integer)getProperty("code");
+    return getPropertyInt("code");
   }
-  public void setCode(int code) {
-    setProperty("code",code);
+  
+  public static Builder makeError() {
+    return new Builder("error");
   }
   
-  public static <T extends ErrorObject>ErrorObjectGenerator<T> makeError() {
-    return new ErrorObjectGenerator<T>();
+  public static ErrorObject makeError(int code, String message) {
+    return makeError()
+      .code(code)
+      .displayName(message)
+      .get();
   }
   
-  @SuppressWarnings("unchecked")
-  public static class ErrorObjectGenerator<T extends ErrorObject> extends ASObjectGenerator<T> {
-    public ErrorObjectGenerator() {
-      super((Class<? extends T>) ErrorObject.class);
-    }
-    public ErrorObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends ErrorObjectGenerator<T>>X code(int code) {
-      item.setCode(code);
-      return (X)this;
+  @Name("error")
+  @Properties(@Property(name="code",to=Integer.class))
+  public final static class Builder 
+    extends ASObject.Builder<ErrorObject,Builder> {
+    public Builder() {
+      super(ErrorObject.class,Builder.class);
+    }
+    public Builder(String objectType) {
+      super(objectType,ErrorObject.class,Builder.class);
+    }
+    public Builder(Map<String,Object> map) {
+      super(map,ErrorObject.class,Builder.class);
+    }
+    public Builder template() {
+      return new Builder(map.build());
+    }
+    public Builder code(int code) {
+      set("code",code);
+      return this;
+    }
+    public ErrorObject get() {
+      return new ErrorObject(map.build());
     }
   }
 }

Propchange: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ErrorObject.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EventObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EventObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EventObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/EventObject.java Thu Nov 10 21:48:45 2011
@@ -17,128 +17,114 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.Collection;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 
-@Name("event")
 public class EventObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -7607925831414516450L;
   public static final String ATTENDING = "attending";
   public static final String ENDTIME = "endTime";
   public static final String MAYBEATTENDING = "maybeAttending";
   public static final String NOTATTENDING = "notAttending";
   public static final String STARTTIME = "startTime";
   
-  public EventObject() {
-  }
-  
-  public EventObject(String displayName) {
-    setDisplayName(displayName);
+  public EventObject(Map<String,Object> map) {
+    super(map,EventBuilder.class,EventObject.class);
   }
   
-  protected Collection<ASObject> getcol(String name, boolean create) {
-    Collection<ASObject> col = getProperty(name);
-    if (col == null && create) {
-      col = new Collection<ASObject>();
-      setProperty(name,col);
-    }
-    return col;
+  public <X extends EventObject, M extends Builder<X,M>>EventObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public Collection<ASObject> getAttending() {
-    return getcol(ATTENDING,false);
-  }
-  
-  public Collection<ASObject> getAttending(boolean create) {
-    return getcol(ATTENDING,create);
-  }
-  
-  public void setAttending(Collection<ASObject> attending) {
-    setProperty(ATTENDING, attending);
+    return getProperty(ATTENDING);
   }
   
   public DateTime getEndTime() {
     return getProperty(ENDTIME);
   }
   
-  public void setEndTime(DateTime endTime) {
-    setProperty(ENDTIME, endTime);
-  }
-  
   public Collection<ASObject> getMaybeAttending() {
-    return getcol(MAYBEATTENDING,false);
-  }
-  
-  public Collection<ASObject> getMaybeAttending(boolean create) {
-    return getcol(MAYBEATTENDING,create);
-  }
-  
-  public void setMaybeAttending(Collection<ASObject> maybeAttending) {
-    setProperty(MAYBEATTENDING, maybeAttending);
+    return getProperty(MAYBEATTENDING);
   }
   
   public Collection<ASObject> getNotAttending() {
-    return getcol(NOTATTENDING,false);
+    return getProperty(NOTATTENDING);
   }
   
-  public Collection<ASObject> getNotAttending(boolean create) {
-    return getcol(NOTATTENDING,create);
+  public DateTime getStartTime() {
+    return getProperty(STARTTIME);
   }
   
-  public void setNotAttending(Collection<ASObject> notAttending) {
-    setProperty(NOTATTENDING, notAttending);
+  public static EventBuilder makeEvent() {
+    return new EventBuilder("event");
   }
   
-  public DateTime getStartTime() {
-    return getProperty(STARTTIME);
+  public static EventBuilder makeEvent(String objectType) {
+    return new EventBuilder(objectType);
   }
   
-  public void setStartTime(DateTime startTime) {
-    setProperty(STARTTIME, startTime);
-  }
+  @Name("event")
+  public static final class EventBuilder extends Builder<EventObject,EventBuilder> {
+
+    public EventBuilder() {
+      super(EventObject.class,EventBuilder.class);
+    }
 
-  public static <T extends EventObject>EventObjectGenerator<T> makeEvent() {
-    return new EventObjectGenerator<T>();
+    public EventBuilder(Map<String, Object> map) {
+      super(map, EventObject.class,EventBuilder.class);
+    }
+
+    public EventBuilder(String objectType) {
+      super(objectType, EventObject.class,EventBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class EventObjectGenerator<T extends EventObject> extends ASObjectGenerator<T> {
+  public static abstract class Builder<X extends EventObject,M extends Builder<X,M>>
+    extends ASObject.Builder<X,M> {
 
-    public EventObjectGenerator() {
-      super((Class<? extends T>) EventObject.class);
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
     }
     
-    public EventObjectGenerator(Class<? extends T> _class) {
-      super(_class);
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
     }
     
-    public <X extends EventObjectGenerator<T>>X attending(Collection<ASObject> col) {
-      item.setAttending(col);
-      return (X)this;
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    
-    public <X extends EventObjectGenerator<T>>X endTime(DateTime dt) {
-      item.setEndTime(dt);
-      return (X)this;
+
+    public <T extends ASObject>M attending(Collection<T> col) {
+      set(ATTENDING, col);
+      return (M)this;
     }
     
-    public <X extends EventObjectGenerator<T>>X maybeAttending(Collection<ASObject> col) {
-      item.setMaybeAttending(col);
-      return (X)this;
+    public M endTime(DateTime dt) {
+      set(ENDTIME, dt);
+      return (M)this;
     }
     
-    public <X extends EventObjectGenerator<T>>X notAttending(Collection<ASObject> col) {
-      item.setNotAttending(col);
-      return (X)this;
+    public <T extends ASObject>M maybeAttending(Collection<T> col) {
+      set(MAYBEATTENDING, col);
+      return (M)this;
     }
     
-    public <X extends EventObjectGenerator<T>>X startTime(DateTime t) {
-      item.setStartTime(t);
-      return (X)this;
+    public <T extends ASObject>M notAttending(Collection<T> col) {
+      set(NOTATTENDING, col);
+      return (M)this;
     }
+    
+    public M startTime(DateTime t) {
+      set(STARTTIME, t);
+      return (M)this;
+    }    
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/FileObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/FileObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/FileObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/FileObject.java Thu Nov 10 21:48:45 2011
@@ -17,79 +17,124 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import javax.activation.MimeType;
-import javax.activation.MimeTypeParseException;
 
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 import org.apache.abdera2.common.iri.IRI;
 import org.apache.abdera2.common.mediatype.MimeTypeHelper;
 
-@Name("file")
 public class FileObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -5449136149228249949L;
   public static final String FILEURL = "fileUrl";
   
-  public FileObject() {
+  public FileObject(Map<String,Object> map) {
+    super(map,FileBuilder.class,FileObject.class);
   }
   
-  public FileObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends FileObject, M extends Builder<X,M>>FileObject(Map<String,Object> map, Class<M> _class, Class<X> _obj) {
+    super(map,_class,_obj);
   }
   
   public IRI getFileUrl() {
     return getProperty(FILEURL);
   }
   
-  public void setFileUrl(IRI fileUrl) {
-    setProperty(FILEURL, fileUrl);
-  }
-  
-  public void setFileUrl(String fileUrl) {
-    setFileUrl(new IRI(fileUrl));
-  }
-  
   public MimeType getMimeType() {
     return getProperty("mimeType");
   }
   
-  public void setMimeType(MimeType mimeType) {
-    setProperty("mimeType", MimeTypeHelper.unmodifiableMimeType(mimeType));
+  public static FileBuilder makeFile() {
+    return new FileBuilder("file");
   }
   
-  public void setMimeType(String mimeType) {
-    setProperty("mimeType", MimeTypeHelper.unmodifiableMimeType(mimeType));
+  public static FileObject makeFile(
+    String displayName, 
+    String fileUrl, 
+    String mimeType) {
+    return makeFile()
+      .displayName(displayName)
+      .fileUrl(fileUrl)
+      .mimeType(mimeType)
+      .get();
+  }
+  
+  public static FileObject makeFile(
+    String displayName, 
+    IRI fileUrl, 
+    String mimeType) {
+    return makeFile()
+      .displayName(displayName)
+      .fileUrl(fileUrl)
+      .mimeType(mimeType)
+      .get();
+  }
+  
+  public static FileObject makeFile(
+    String displayName, 
+    String fileUrl, 
+    MimeType mimeType) {
+    return makeFile()
+      .displayName(displayName)
+      .fileUrl(fileUrl)
+      .mimeType(mimeType)
+      .get();
+  }
+  
+  public static FileObject makeFile(
+    String displayName, 
+    IRI fileUrl, 
+    MimeType mimeType) {
+    return makeFile()
+      .displayName(displayName)
+      .fileUrl(fileUrl)
+      .mimeType(mimeType)
+      .get();
+  }
+  
+  @Name("file")
+  public static final class FileBuilder extends Builder<FileObject,FileBuilder> {
+    public FileBuilder() {
+      super(FileObject.class,FileBuilder.class);
+    }
+    public FileBuilder(Map<String, Object> map) {
+      super(map, FileObject.class,FileBuilder.class);
+    }
+    public FileBuilder(String objectType) {
+      super(objectType, FileObject.class,FileBuilder.class);
+    }
   }
   
-  public static <T extends FileObject>FileObjectGenerator<T> makeFile() {
-    return new FileObjectGenerator<T>();
-  }
   
   @SuppressWarnings("unchecked")
-  public static class FileObjectGenerator<T extends FileObject> extends ASObjectGenerator<T> {
-    public FileObjectGenerator() {
-      super((Class<? extends T>) FileObject.class);
-    }
-    public FileObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends FileObjectGenerator<T>>X fileUrl(IRI iri) {
-      item.setFileUrl(iri);
-      return (X)this;
-    }
-    public <X extends FileObjectGenerator<T>>X fileUrl(String uri) {
-      item.setFileUrl(uri);
-      return (X)this;
-    }
-    public <X extends FileObjectGenerator<T>>X mimeType(MimeType mimeType) {
-      item.setMimeType(mimeType);
-      return (X)this;
-    }
-    public <X extends FileObjectGenerator<T>>X mimeType(String mimeType) {
-      item.setMimeType(mimeType);
-      return (X)this;
+  public static abstract class Builder<X extends FileObject, M extends Builder<X,M>>
+    extends ASObject.Builder<X,M> {
+    public Builder(Class<X> _class, Class<M> _builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X> _class, Class<M> _builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X> _class, Class<M> _builder) {
+      super(map,_class,_builder);
+    }
+    public M fileUrl(IRI iri) {
+      set(FILEURL,iri);
+      return (M)this;
+    }
+    public M fileUrl(String uri) {
+      return fileUrl(new IRI(uri));
+    }
+    public M mimeType(MimeType mimeType) {
+      set("mimeType",MimeTypeHelper.unmodifiableMimeType(mimeType));
+      return (M)this;
+    }
+    public M mimeType(String mimeType) {
+      set("mimeType",MimeTypeHelper.unmodifiableMimeType(mimeType));
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/GroupObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/GroupObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/GroupObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/GroupObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,42 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("group")
 public class GroupObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -8735573352110428150L;
-  
-  public GroupObject() {}
   
-  public GroupObject(String displayName) {
-    setDisplayName(displayName);
+  public static Builder makeGroup() {
+    return new Builder("group");
   }
-
-  public static <T extends GroupObject>GroupObjectGenerator<T> makeGroup() {
-    return new GroupObjectGenerator<T>();
+  
+  public static GroupObject makeGroup(String id) {
+    return makeGroup().id(id).get();
   }
   
-  public static class GroupObjectGenerator<T extends GroupObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public GroupObjectGenerator() {
-      super((Class<? extends T>) GroupObject.class);
+  @Name("group")
+  public static final class Builder extends ASObject.Builder<GroupObject,Builder> {
+    public Builder() {
+      super(GroupObject.class,Builder.class);
+    }
+    public Builder(String objectType) {
+      super(objectType,GroupObject.class,Builder.class);
     }
-    public GroupObjectGenerator(Class<? extends T> _class) {
-      super(_class);
+    public Builder(Map<String,Object> map) {
+      super(map,GroupObject.class,Builder.class);
     }
   }
+  
+  public GroupObject(Map<String,Object> map) {
+    super(map,Builder.class,GroupObject.class);
+  }
+  
+  public <X extends GroupObject, M extends ASObject.Builder<X,M>>GroupObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
+  }
+  
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ImageObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ImageObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ImageObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ImageObject.java Thu Nov 10 21:48:45 2011
@@ -17,46 +17,62 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.activities.model.MediaLink;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("image")
 public class ImageObject 
   extends ASObject {
 
-  private static final long serialVersionUID = 2130182696482757451L;
   public static final String FULLIMAGE = "fullImage";
   
-  public ImageObject() {}
-  
-  public ImageObject(String displayName) {
-    setDisplayName(displayName);
+  public ImageObject(Map<String,Object> map) {
+    super(map,ImageBuilder.class,ImageObject.class);
   }
   
+  public <X extends ImageObject, M extends Builder<X,M>>ImageObject(Map<String,Object> map, Class<M> _class,Class<X>_obj) {
+    super(map,_class,_obj);
+  }
+    
   public MediaLink getFullImage() {
     return getProperty(FULLIMAGE);
   }
-  
-  public void setFullImage(MediaLink fullImage) {
-    setProperty(FULLIMAGE, fullImage);
+
+  public static ImageBuilder makeImage() {
+    return new ImageBuilder("image");
   }
   
-  public static <T extends ImageObject>ImageObjectGenerator<T> makeImage() {
-    return new ImageObjectGenerator<T>();
+  @Name("image")
+  public static final class ImageBuilder extends Builder<ImageObject,ImageBuilder> {
+    public ImageBuilder() {
+      super(ImageObject.class, ImageBuilder.class);
+    }
+    public ImageBuilder(Map<String, Object> map) {
+      super(map, ImageObject.class, ImageBuilder.class);
+    }
+    public ImageBuilder(String objectType) {
+      super(objectType,ImageObject.class, ImageBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class ImageObjectGenerator<T extends ImageObject> extends ASObjectGenerator<T> {
-    public ImageObjectGenerator() {
-      super((Class<? extends T>) ImageObject.class);
-    }
-    public ImageObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends ImageObjectGenerator<T>>X fullImage(MediaLink fullImage) {
-      item.setFullImage(fullImage);
-      return (X)this;
+  public static abstract class Builder<X extends ImageObject, M extends Builder<X,M>> 
+    extends ASObject.Builder<X,M> {
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
+    }
+    public M fullImage(MediaLink fullImage) {
+      set(FULLIMAGE, fullImage);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Mood.java Thu Nov 10 21:48:45 2011
@@ -17,61 +17,63 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASBase;
-import org.apache.abdera2.activities.model.Generator;
 import org.apache.abdera2.activities.model.MediaLink;
+import org.apache.abdera2.common.iri.IRI;
 
-public class Mood extends ASBase {
+public final class Mood extends ASBase {
 
-  private static final long serialVersionUID = -3361108212621494744L;
   public static final String IMAGE = "image";
   public static final String DISPLAYNAME = "displayName";
   
-  public Mood() {}
-  
-  public Mood(String displayName) {
-    setDisplayName(displayName);
+  protected Mood(Map<String,Object> map) {
+    super(map,Builder.class,Mood.class);
   }
   
   public String getDisplayName() {
     return getProperty(DISPLAYNAME);
   }
   
-  public void setDisplayName(String displayName) {
-    setProperty(DISPLAYNAME, displayName);
-  }
-  
   public MediaLink getImage() {
     return getProperty(IMAGE);
   }
   
-  public void setImage(MediaLink image) {
-    setProperty(IMAGE, image);
-  }
-  
   public String toString() {
     return getDisplayName();
   }
   
-  public static <T extends Mood>MoodGenerator<T> makeMood() {
-    return new MoodGenerator<T>();
+  public static Builder makeMood() {
+    return new Builder();
   }
   
-  @SuppressWarnings("unchecked")
-  public static class MoodGenerator<T extends Mood> extends Generator<T> {
-    public MoodGenerator() {
-      super((Class<? extends T>) Mood.class);
+  public static Mood makeMood(String name, MediaLink image) {
+    return makeMood().displayName(name).image(image).get();
+  }
+  
+  public static Mood makeMood(String name, String image) {
+    return makeMood().displayName(name).image(MediaLink.makeMediaLink(image)).get();
+  }
+  
+  public static Mood makeMood(String name, IRI image) {
+    return makeMood().displayName(name).image(MediaLink.makeMediaLink(image)).get();
+  }
+
+  public static final class Builder extends ASBase.Builder<Mood,Builder> {
+    public Builder() {
+      super(Mood.class,Builder.class);
     }
-    public MoodGenerator(Class<T> _class) {
-      super(_class);
+    protected Builder(Map<String,Object> map) {
+      super(map,Mood.class,Builder.class);
     }
-    public <X extends MoodGenerator<T>>X displayName(String dn) {
-      item.setDisplayName(dn);
-      return (X)this;
+    public Builder displayName(String dn) {
+      set(DISPLAYNAME,dn);
+      return this;
     }
-    public <X extends MoodGenerator<T>>X image(MediaLink link) {
-      item.setImage(link);
-      return (X)this;
+    public Builder image(MediaLink link) {
+      set(IMAGE, link);
+      return this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/MovieObject.java Thu Nov 10 21:48:45 2011
@@ -1,5 +1,7 @@
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;
 import org.apache.abdera2.activities.model.ASObject;
@@ -11,116 +13,109 @@ import org.joda.time.Duration;
  * A simple "objectType":"movie" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("movie")
-@Properties({
-  @Property(name="preview",to=MediaLink.class),
-  @Property(name="duration",to=Duration.class)
-})
 @SuppressWarnings("unchecked")
 public class MovieObject extends CreativeWork {
 
-  private static final long serialVersionUID = -1551754630697817614L;
 
-  public MovieObject() {}
+  public MovieObject(Map<String,Object> map) {
+    super(map,MovieBuilder.class,MovieObject.class);
+  }
   
-  public MovieObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends MovieObject, M extends Builder<X,M>>MovieObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public <T extends ASObject>T getActors() {
     return (T)getProperty("actors");
   }
   
-  public void setActors(ASObject actors) {
-    setProperty("actors", actors);
-  }
-  
   public <T extends ASObject>T getDirector() {
     return (T)getProperty("director");
   }
   
-  public void setDirector(ASObject director) {
-    setProperty("director", director);
-  }
-  
   public Duration getDuration() {
     return getProperty("duration");
   }
   
-  public void setDuration(Duration duration) {
-    setProperty("duration", duration);
-  }
-  
   public <T extends ASObject>T getMusicBy() {
     return (T)getProperty("musicBy");
   }
   
-  public void setMusicBy(ASObject musicBy) {
-    setProperty("musicBy", musicBy);
-  }
-  
   public <T extends ASObject>T getProducer() {
     return (T)getProperty("producer");
   }
   
-  public void setProducer(ASObject producer) {
-    setProperty("producer", producer);
-  }
-  
   public <T extends ASObject>T getProductionCompany() {
     return (T)getProperty("productionCompany");
   }
   
-  public void setProductionCompany(ASObject org) {
-    setProperty("productionCompany", org);
-  }
-  
   public MediaLink getPreview() {
     return getProperty("preview");
   }
   
-  public void setPreview(MediaLink link) {
-    setProperty("preview", link);
+  public static MovieBuilder makeMovie() {
+    return new MovieBuilder("movie");
   }
   
-  public static <T extends MovieObject>MovieObjectGenerator<T> makeMovie() {
-    return new MovieObjectGenerator<T>();
+  @Name("movie")
+  @Properties({
+    @Property(name="preview",to=MediaLink.class),
+    @Property(name="duration",to=Duration.class)
+  })
+  public static final class MovieBuilder extends Builder<MovieObject,MovieBuilder> {
+
+    public MovieBuilder() {
+      super(MovieObject.class, MovieBuilder.class);
+    }
+
+    public MovieBuilder(Map<String, Object> map) {
+      super(map, MovieObject.class, MovieBuilder.class);
+    }
+
+    public MovieBuilder(String objectType) {
+      super(objectType, MovieObject.class, MovieBuilder.class);
+    }
+    
   }
   
-  public static class MovieObjectGenerator<T extends MovieObject> extends CreativeWorkGenerator<T> {
-    public MovieObjectGenerator() {
-      super((Class<T>) MovieObject.class);
+  public static class Builder<X extends MovieObject, M extends Builder<X,M>> 
+    extends CreativeWork.Builder<X,M> {
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
     }
-    public MovieObjectGenerator(Class<T> _class) {
-      super(_class);
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends MovieObjectGenerator<T>>X actors(ASObject obj) {
-      item.setActors(obj);
-      return (X)this;
+    public M actors(ASObject obj) {
+      set("actors",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X director(ASObject obj) {
-      item.setDirector(obj);
-      return (X)this;
+    public M director(ASObject obj) {
+      set("director",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X duration(Duration obj) {
-      item.setDuration(obj);
-      return (X)this;
+    public M duration(Duration obj) {
+      set("duration",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X musicBy(ASObject obj) {
-      item.setMusicBy(obj);
-      return (X)this;
+    public M musicBy(ASObject obj) {
+      set("musicBy",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X preview(MediaLink obj) {
-      item.setPreview(obj);
-      return (X)this;
+    public M preview(MediaLink obj) {
+      set("preview",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X producer(ASObject obj) {
-      item.setProducer(obj);
-      return (X)this;
+    public M producer(ASObject obj) {
+      set("producer",obj);
+      return (M)this;
     }
-    public <X extends MovieObjectGenerator<T>>X productionCompany(ASObject obj) {
-      item.setProductionCompany(obj);
-      return (X)this;
+    public M productionCompany(ASObject obj) {
+      set("productionCompany",obj);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NameObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NameObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NameObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NameObject.java Thu Nov 10 21:48:45 2011
@@ -1,133 +1,120 @@
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.iri.IRI;
 
-@org.apache.abdera2.common.anno.Name("name")
 public class NameObject 
   extends ASObject {
 
-  private static final long serialVersionUID = 5503270370616022868L;
-
-  public NameObject() {
-    super();
+  public NameObject(Map<String,Object> map) {
+    super(map,NameBuilder.class,NameObject.class);
+  }
+  
+  public <X extends NameObject, M extends Builder<X,M>>NameObject(Map<String,Object> map, Class<M> _class, Class<X>_obj) {
+    super(map,_class,_obj);
   }
 
   public String getFamilyName() {
     return getProperty("familyName");
   }
   
-  public void setFamilyName(String val) {
-    setProperty("familyName", val);
-  }
-  
   public String getFormatted() {
     return getProperty("formatted");
   }
   
-  public void setFormatted(String val) {
-    setProperty("formatted", val);
-  }
-  
   public String getGivenName() {
     return getProperty("givenName");
   }
   
-  public void setGivenName(String val) {
-    setProperty("givenName", val);
-  }
-  
   public String getHonorificPrefix() {
     return getProperty("honorificPrefix");
   }
   
-  public void setHonorificPrefix(String val) {
-    setProperty("honorificPrefix", val);
-  }
-  
   public String getHonorificSuffix() {
     return getProperty("honorificSuffix");
   }
   
-  public void setHonorificSuffix(String val) {
-    setProperty("honorificSuffix", val);
-  }
-  
   public String getMiddleName() {
     return getProperty("middleName");
   }
   
-  public void setMiddleName(String val) {
-    setProperty("middleName", val);
-  }
-  
   public String getPronunciation() {
     return getProperty("pronunciation");
   }
   
-  public void setPronunciation(String val) {
-    setProperty("pronunciation", val);
-  }
-  
   public IRI getPronunciationUrl() {
     return getProperty("pronunciationUrl");
   }
   
-  public void setPronunciationUrl(IRI val) {
-    setProperty("pronunciationUrl", val);
-  }
-  
-  public void setPronunciationUrl(String val) {
-    setPronunciationUrl(new IRI(val));
+  public static NameBuilder makeName() {
+    return new NameBuilder("name");
   }
   
-  public static <T extends NameObject>NameObjectGenerator<T> makeName() {
-    return new NameObjectGenerator<T>();
+  @org.apache.abdera2.common.anno.Name("name")
+  public static final class NameBuilder extends Builder<NameObject,NameBuilder> {
+
+    public NameBuilder() {
+      super(NameObject.class,NameBuilder.class);
+    }
+
+    public NameBuilder(Map<String, Object> map) {
+      super(map, NameObject.class,NameBuilder.class);
+    }
+
+    public NameBuilder(String objectType) {
+      super(objectType, NameObject.class,NameBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class NameObjectGenerator<T extends NameObject> extends ASObjectGenerator<T> {
-    public NameObjectGenerator() {
-      super((Class<? extends T>) NameObject.class);
-    }
-    public NameObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends NameObjectGenerator<T>>X familyName(String fn) {
-      item.setFamilyName(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X formatted(String fn) {
-      item.setFormatted(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X givenName(String fn) {
-      item.setGivenName(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X honorificPrefix(String fn) {
-      item.setHonorificPrefix(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X honorificSuffix(String fn) {
-      item.setHonorificSuffix(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X middleName(String fn) {
-      item.setMiddleName(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X pronunciation(String fn) {
-      item.setPronunciation(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X pronunciationUrl(String fn) {
-      item.setPronunciationUrl(fn);
-      return (X)this;
-    }
-    public <X extends NameObjectGenerator<T>>X pronunciationUrl(IRI fn) {
-      item.setPronunciationUrl(fn);
-      return (X)this;
+  public static abstract class Builder<X extends NameObject, M extends Builder<X,M>> 
+    extends ASObject.Builder<X,M> {
+    public Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
+    }
+    public Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
+    }
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
+    }
+    public M familyName(String fn) {
+      set("familyName",fn);
+      return (M)this;
+    }
+    public M formatted(String fn) {
+      set("formatted",fn);
+      return (M)this;
+    }
+    public M givenName(String fn) {
+      set("givenName",fn);
+      return (M)this;
+    }
+    public M honorificPrefix(String fn) {
+      set("honorificPrefix",fn);
+      return (M)this;
+    }
+    public M honorificSuffix(String fn) {
+      set("honorificSuffix",fn);
+      return (M)this;
+    }
+    public M middleName(String fn) {
+      set("middleName",fn);
+      return (M)this;
+    }
+    public M pronunciation(String fn) {
+      set("pronunciation",fn);
+      return (M)this;
+    }
+    public M pronunciationUrl(String fn) {
+      return pronunciationUrl(fn);
+    }
+    public M pronunciationUrl(IRI fn) {
+      set("pronunciationUrl",fn);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NoteObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NoteObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NoteObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/NoteObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,37 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
+import java.util.Map;
+
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("note")
 public class NoteObject 
   extends ASObject {
-
-  private static final long serialVersionUID = -1394391975713468634L;
-  
-  public NoteObject() {}
   
-  public NoteObject(String displayName) {
-    setDisplayName(displayName);
-  }  
-  
-  public static <T extends NoteObject>NoteObjectGenerator<T> makeNote() {
-    return new NoteObjectGenerator<T>();
+  public static <T extends NoteObject>Builder makeNote() {
+    return new Builder("note");
   }
   
-  public static class NoteObjectGenerator<T extends NoteObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public NoteObjectGenerator() {
-      super((Class<? extends T>) NoteObject.class);
+  @Name("note")
+  public static class Builder extends ASObject.Builder<NoteObject,Builder> {
+    public Builder() {
+      super(NoteObject.class,Builder.class);
+    }
+    public Builder(String objectType) {
+      super(objectType,NoteObject.class,Builder.class);
     }
-    public NoteObjectGenerator(Class<? extends T> _class) {
-      super(_class);
+    public Builder(Map<String,Object> map) {
+      super(map,NoteObject.class,Builder.class);
     }
   }
+  
+  public NoteObject(Map<String,Object> map) {
+    super(map,Builder.class,NoteObject.class);
+  }
+  
+  public <X extends NoteObject, M extends ASObject.Builder<X,M>>NoteObject(Map<String,Object> map,Class<M> _class,Class<X>_obj) {
+    super(map,_class,_obj);
+  }
+  
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/Objects.java Thu Nov 10 21:48:45 2011
@@ -1,125 +1,144 @@
 package org.apache.abdera2.activities.model.objects;
 
 import org.apache.abdera2.activities.model.ASObject;
+import org.apache.abdera2.activities.model.ASObject.ASObjectBuilder;
 
-public class Objects {
+public final class Objects {
 
+  private Objects() {}
+  
   /**
    * Special AS Object that represents the authenticated user
    */
-  public static ASObject SELF() {
-    return new ASObject("@self");
+  
+  public static final ASObject SELF = SELF().get();
+  public static final ASObject ME = ME().get();
+  public static final ASObject FRIENDS = FRIENDS().get();
+  public static final ASObject NETWORK = NETWORK().get();
+  public static final ASObject ALL = ALL().get();
+  public static final ASObject PUBLIC = PUBLIC().get();
+  
+  public static ASObjectBuilder SELF() {
+    return ASObject.makeObject("@self");
   }
   
   /**
    * Special AS Object that represents the authenticated user.
    * synonymous with @self
    */
-  public static ASObject ME() {
-    return new ASObject("@me");
+  public static ASObjectBuilder ME() {
+    return ASObject.makeObject("@me");
   }
   
   /**
    * Special AS Object that represents the authenticated users 
    * collection of direct contacts
    */
-  public static ASObject FRIENDS() {
-    return new ASObject("@friends");
+  public static ASObjectBuilder FRIENDS() {
+    return ASObject.makeObject("@friends");
   }
   
   /**
    * Special AS Object that represents a subset of the authenticated users
    * collection of direct contacts
    */
-  public static ASObject FRIENDS(String id) {
-    ASObject obj = FRIENDS();
-    obj.setId(id);
-    return obj;
+  public static ASObjectBuilder FRIENDS(String id) {
+    return ASObject.makeObject("@friends").id(id);
   }
   
   /**
    * Special AS Object that represents the authenticated users collection
    * of extended contacts (e.g. friends of friends)
    */
-  public static ASObject NETWORK() {
-    return new ASObject("@network");
+  public static ASObjectBuilder NETWORK() {
+    return ASObject.makeObject("@network");
   }
   
   /**
    * Special AS Object that represents everyone. synonymous with @public
    */
-  public static ASObject ALL() {
-    return new ASObject("@all");
+  public static ASObjectBuilder ALL() {
+    return ASObject.makeObject("@all");
   }
   
   /**
    * Special AS Object that represents everyone
    */
-  public static ASObject PUBLIC() {
-    return new ASObject("@public");
+  public static ASObjectBuilder PUBLIC() {
+    return ASObject.makeObject("@public");
   }
   
   /**
    * Create an anonymous AS Object (no objectType property)
    */
-  public static ASObject anonymousObject(String id) {
-    ASObject obj = new ASObject();
-    obj.setObjectType(null);
-    obj.setId(id);
-    return obj;
+  public static ASObjectBuilder anonymousObject(String id) {
+    return ASObject.makeObject().id(id);
   }
   
-  public static ASObject DISCONTINUED() {
+  public static final ASObject DISCONTINUED = DISCONTINUED().get();
+  public static final ASObject INSTOCK = INSTOCK().get();
+  public static final ASObject INSTOREONLY = INSTOREONLY().get();
+  public static final ASObject ONLINEONLY = ONLINEONLY().get();
+  public static final ASObject OUTOFSTOCK = OUTOFSTOCK().get();
+  public static final ASObject PREORDER = PREORDER().get();
+  public static final ASObject EBOOK = EBOOK().get();
+  public static final ASObject HARDCOVER = HARDCOVER().get();
+  public static final ASObject PAPERBACK = PAPERBACK().get();
+  public static final ASObject DAMAGED = DAMAGED().get();
+  public static final ASObject NEW = NEW().get();
+  public static final ASObject REFURBISHED = REFURBISHED().get();
+  public static final ASObject USED = USED().get();
+  
+  public static ASObjectBuilder DISCONTINUED() {
     return anonymousObject("discontinued");
   }
   
-  public static ASObject INSTOCK() {
+  public static ASObjectBuilder INSTOCK() {
     return anonymousObject("in-stock");
   }
   
-  public static ASObject INSTOREONLY() {
+  public static ASObjectBuilder INSTOREONLY() {
     return anonymousObject("in-store-only");
   }
   
-  public static ASObject ONLINEONLY() {
+  public static ASObjectBuilder ONLINEONLY() {
     return anonymousObject("online-only");
   }
   
-  public static ASObject OUTOFSTOCK() {
+  public static ASObjectBuilder OUTOFSTOCK() {
     return anonymousObject("out-of-stock");
   }
   
-  public static ASObject PREORDER() {
+  public static ASObjectBuilder PREORDER() {
     return anonymousObject("pre-order");
   }
   
-  public static ASObject EBOOK() {
+  public static ASObjectBuilder EBOOK() {
     return anonymousObject("ebook");
   }
   
-  public static ASObject HARDCOVER() {
+  public static ASObjectBuilder HARDCOVER() {
     return anonymousObject("hardcover");
   }
   
-  public static ASObject PAPERBACK() {
+  public static ASObjectBuilder PAPERBACK() {
     return anonymousObject("paperback");
   }
   
-  public static ASObject DAMAGED() {
+  public static ASObjectBuilder DAMAGED() {
     return anonymousObject("damaged");
   }
   
-  public static ASObject NEW() {
+  public static ASObjectBuilder NEW() {
     return anonymousObject("new");
   }
   
-  public static ASObject REFURBISHED() {
+  public static ASObjectBuilder REFURBISHED() {
     return anonymousObject("refurbished");
   }
   
-  public static ASObject USED() {
+  public static ASObjectBuilder USED() {
     return anonymousObject("used");
   }
-
   
 }



Mime
View raw message