abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r1200583 [4/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/OfferObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OfferObject.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;
@@ -10,128 +12,117 @@ import org.joda.time.DateTime;
  * A simple "objectType":"offer" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("offer")
-@Properties({
-  @Property(name="validFrom",to=DateTime.class),
-  @Property(name="validUntil",to=DateTime.class)
-})
 @SuppressWarnings("unchecked")
 public class OfferObject extends ASObject {
 
-  private static final long serialVersionUID = 8693274483912587801L;
 
-  public OfferObject() {}
+  public OfferObject(Map<String,Object> map) {
+    super(map,OfferBuilder.class,OfferObject.class);
+  }
   
-  public OfferObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends OfferObject, M extends Builder<X,M>>OfferObject(Map<String,Object> map,Class<M>_class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public <T extends ASObject>T getAvailability() {
     return (T)getProperty("availability");
   }
   
-  public void setAvailability(ASObject availability) {
-    setProperty("availability", availability);
-  }
-  
   public <T extends ASObject>T getCondition() {
     return (T)getProperty("condition");
   }
   
-  public void setCondition(ASObject condition) {
-    setProperty("condition", condition);
-  }
-  
   public <T extends ASObject>T getItem() {
     return (T)getProperty("item");
   }
   
-  public void setItem(ASObject item) {
-    setProperty("item", item);
-  }
-  
   public String getPrice() {
     return getProperty("price");
   }
   
-  public void setPrice(String price) {
-    setProperty("price", price);
-  }
-  
   public String getCurrency() {
     return getProperty("currency");
   }
   
-  public void setCurrency(String currency) {
-    setProperty("currency",currency);
-  }
-  
   public DateTime getValidUntil() {
     return getProperty("validUntil");
   }
   
-  public void setValidUntil(DateTime date) {
-    setProperty("validUntil", date);
-  }
-  
   public DateTime getValidFrom() {
     return getProperty("validFrom");
   }
   
-  public void setValidFrom(DateTime date) {
-    setProperty("validFrom", date);
-  }
-
   public <T extends ASObject>T getRestriction() {
     return (T)getProperty("restriction");
   }
   
-  public void setRestriction(ASObject restriction) {
-    setProperty("restriction", restriction);
+  public static OfferBuilder makeOffer() {
+    return new OfferBuilder("offer");
   }
   
-  public static <T extends OfferObject>OfferObjectGenerator<T> makeOffer() {
-    return new OfferObjectGenerator<T>();
+  @Name("offer")
+  @Properties({
+    @Property(name="validFrom",to=DateTime.class),
+    @Property(name="validUntil",to=DateTime.class)
+  })
+  public static final class OfferBuilder extends Builder<OfferObject,OfferBuilder> {
+
+    public OfferBuilder() {
+      super(OfferObject.class,OfferBuilder.class);
+    }
+
+    public OfferBuilder(Map<String, Object> map) {
+      super(map, OfferObject.class,OfferBuilder.class);
+    }
+
+    public OfferBuilder(String objectType) {
+      super(objectType, OfferObject.class,OfferBuilder.class);
+    }
+    
   }
   
-  public static class OfferObjectGenerator<T extends OfferObject> extends ASObjectGenerator<T> {
-    public OfferObjectGenerator() {
-      super((Class<T>)OfferObject.class);
+  public static abstract class Builder<X extends OfferObject,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 OfferObjectGenerator(Class<T> _class) {
-      super(_class);
+    public Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends OfferObjectGenerator<T>>X availability(ASObject obj) {
-      item.setAvailability(obj);
-      return (X)this;
+    public M availability(ASObject obj) {
+      set("availability",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X condition(ASObject obj) {
-      item.setCondition(obj);
-      return (X)this;
+    public M condition(ASObject obj) {
+      set("condition",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X currency(String obj) {
-      item.setCurrency(obj);
-      return (X)this;
+    public M currency(String obj) {
+      set("currency",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X item(ASObject obj) {
-      item.setItem(obj);
-      return (X)this;
+    public M item(ASObject obj) {
+      set("item",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X price(String obj) {
-      item.setPrice(obj);
-      return (X)this;
+    public M price(String obj) {
+      set("price",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X restriction(ASObject obj) {
-      item.setRestriction(obj);
-      return (X)this;
+    public M restriction(ASObject obj) {
+      set("restriction",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X validFrom(DateTime obj) {
-      item.setValidFrom(obj);
-      return (X)this;
+    public M validFrom(DateTime obj) {
+      set("validFrom",obj);
+      return (M)this;
     }
-    public <X extends OfferObjectGenerator<T>>X validUntil(DateTime obj) {
-      item.setValidUntil(obj);
-      return (X)this;
+    public M validUntil(DateTime obj) {
+      set("validUntil",obj);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OrganizationObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OrganizationObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OrganizationObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/OrganizationObject.java Thu Nov 10 21:48:45 2011
@@ -1,6 +1,7 @@
 package org.apache.abdera2.activities.model.objects;
 
 import java.util.Date;
+import java.util.Map;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;
@@ -9,185 +10,152 @@ import org.apache.abdera2.common.anno.Na
 import org.apache.abdera2.common.iri.IRI;
 import org.joda.time.DateTime;
 
-@Name("organization")
-@Properties({
-  @Property(name="webpage",to=IRI.class),
-  @Property(name="endDate",to=Date.class),
-  @Property(name="startDate",to=Date.class)
-})
 public class OrganizationObject extends ASObject {
 
-  private static final long serialVersionUID = -6983890349791967283L;
-
-  public OrganizationObject() {}
+  public OrganizationObject(Map<String,Object> map) {
+    super(map,OrganizationBuilder.class,OrganizationObject.class);
+  }
   
-  public OrganizationObject(String displayName) {
-    super(displayName);
+  public <X extends OrganizationObject, M extends Builder<X,M>>OrganizationObject(Map<String,Object> map,Class<M>_class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public Address getAddress() {
     return getProperty("address");
   }
   
-  public void setAddress(Address address) {
-    setProperty("address", address);
-  }
-  
   public String getDepartment() {
     return getProperty("department");
   }
   
-  public void setDepartment(String dept) {
-    setProperty("department", dept);
-  }
- 
   public String getDescription() {
     return getProperty("description");
   }
   
-  public void setDescription(String description) {
-    setProperty("description", description);
-  }
-  
   public DateTime getEndDate() {
     return getProperty("endDate");
   }
   
-  public void setEndDate(DateTime date) {
-    setProperty("endDate", date);
-  }
-  
   public String getField() {
     return getProperty("field");
   }
   
-  public void setField(String field) {
-    setProperty("field", field);
-  }
-  
   public String getName() {
     return getProperty("name");
   }
   
-  public void setName(String name) {
-    setProperty("name", name);
-  }
-  
   public String getSalary() {
     return getProperty("salary");
   }
   
-  public void setSalary(String salary) {
-    setProperty("salary", salary);
-  }
-  
   public DateTime getStartDate() {
     return getProperty("startDate");
   }
   
-  public void setStartDate(DateTime date) {
-    setProperty("startDate", date);
-  }
-  
   public String getSubfield() {
     return getProperty("subfield");
   }
   
-  public void setSubfield(String val) {
-    setProperty("subfield", val);
-  }
-  
   public String getTitle() {
     return getProperty("title");
   }
   
-  public void setTitle(String title) {
-    setProperty("title", title);
-  }
-  
   public String getType() {
     return getProperty("type");
   }
   
-  public void setType(String type) {
-    setProperty("type", type);
-  }
-  
   public IRI getWebpage() {
     return getProperty("webpage");
   }
   
-  public void setWebpage(IRI val) {
-    setProperty("webpage", val);
+  public static OrganizationBuilder makeOrganization() {
+    return new OrganizationBuilder("organization");
   }
   
-  public void setWebpage(String val) {
-    setWebpage(new IRI(val));
-  }
-  
-  public static <T extends OrganizationObject>OrganizationObjectGenerator<T> makeOrganization() {
-    return new OrganizationObjectGenerator<T>();
+  @Name("organization")
+  @Properties({
+    @Property(name="webpage",to=IRI.class),
+    @Property(name="endDate",to=Date.class),
+    @Property(name="startDate",to=Date.class)
+  })
+  public static final class OrganizationBuilder extends Builder<OrganizationObject,OrganizationBuilder> {
+
+    public OrganizationBuilder() {
+      super(OrganizationObject.class,OrganizationBuilder.class);
+    }
+
+    public OrganizationBuilder(Map<String, Object> map) {
+      super(map, OrganizationObject.class,OrganizationBuilder.class);
+    }
+
+    public OrganizationBuilder(String objectType) {
+      super(objectType, OrganizationObject.class,OrganizationBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class OrganizationObjectGenerator<T extends OrganizationObject> extends ASObjectGenerator<T> {
-    public OrganizationObjectGenerator() {
-      super((Class<? extends T>) OrganizationObject.class);
-    }
-    public OrganizationObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends OrganizationObjectGenerator<T>>X address(Address address) {
-      item.setAddress(address);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X department(String val) {
-      item.setDepartment(val);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X description(String val) {
-      item.setDescription(val);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X endDate(DateTime dt) {
-      item.setEndDate(dt);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X field(String field) {
-      item.setField(field);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X name(String name) {
-      item.setName(name);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X salary(String salary) {
-      item.setSalary(salary);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X startDate(DateTime dt) {
-      item.setStartDate(dt);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X subfield(String val) {
-      item.setSubfield(val);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X title(String val) {
-      item.setTitle(val);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X type(String val) {
-      item.setType(val);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X webpage(String uri) {
-      item.setWebpage(uri);
-      return (X)this;
-    }
-    public <X extends OrganizationObjectGenerator<T>>X webpage(IRI uri) {
-      item.setWebpage(uri);
-      return (X)this;
+  public static abstract class Builder<X extends OrganizationObject, 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 address(Address address) {
+      set("address",address);
+      return (M)this;
+    }
+    public M department(String val) {
+      set("department",val);
+      return (M)this;
+    }
+    public M description(String val) {
+      set("description",val);
+      return (M)this;
+    }
+    public M endDate(DateTime dt) {
+      set("endDate",dt);
+      return (M)this;
+    }
+    public M field(String field) {
+      set("field",field);
+      return (M)this;
+    }
+    public M name(String name) {
+      set("name",name);
+      return (M)this;
+    }
+    public M salary(String salary) {
+      set("salary",salary);
+      return (M)this;
+    }
+    public M startDate(DateTime dt) {
+      set("startDate",dt);
+      return (M)this;
+    }
+    public M subfield(String val) {
+      set("subfield",val);
+      return (M)this;
+    }
+    public M title(String val) {
+      set("title",val);
+      return (M)this;
+    }
+    public M type(String val) {
+      set("type",val);
+      return (M)this;
+    }
+    public M webpage(String uri) {
+      return webpage(new IRI(uri));
+    }
+    public M webpage(IRI uri) {
+      set("webpage",uri);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PersonObject.java Thu Nov 10 21:48:45 2011
@@ -17,8 +17,7 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.Map;
 
 import org.apache.abdera2.activities.io.gson.Properties;
 import org.apache.abdera2.activities.io.gson.Property;
@@ -26,361 +25,364 @@ import org.apache.abdera2.activities.mod
 import org.apache.abdera2.common.anno.Name;
 import org.apache.abdera2.common.iri.IRI;
 
-@Name("person")
-@Properties({
-  @Property(name="profileUrl",to=IRI.class),
-  @Property(name="thumbnailUrl",to=IRI.class),
-  @Property(name="urls",to=IRI.class),
-  @Property(name="name",to=NameObject.class),
-  @Property(name="preferredName",to=NameObject.class),
-  @Property(name="nativeName",to=NameObject.class),
-  @Property(name="alternateNames",to=NameObject.class),
-  @Property(name="accounts",to=AccountObject.class),
-  @Property(name="addresses",to=Address.class),
-  @Property(name="organizations",to=OrganizationObject.class)
-})
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
 public class PersonObject 
   extends ASObject {
-
-  private static final long serialVersionUID = 5240611684336430061L;
   
-  public PersonObject() { }
+  public PersonObject(Map<String,Object> map) { 
+    super(map,PersonBuilder.class,PersonObject.class);
+  }
   
-  public PersonObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends PersonObject, M extends Builder<X,M>>PersonObject(Map<String,Object> map, Class<M> _class,Class<X>_obj) { 
+    super(map,_class,_obj);
   }
-
+  
   public String getAboutMe() {
     return getProperty("aboutMe");
   }
   
-  public void setAboutMe(String val) {
-    setProperty("aboutMe", val);
-  }
-  
   public String getContactPreference() {
     return getProperty("contactPreference");
   }
   
-  public void setContactPreference(String val) {
-    setProperty("contactPreference", val);
-  }
-  
   public String getDn() {
     return getProperty("dn");
   }
   
-  public void setDn(String val) {
-    setProperty("dn", val);
-  }
-  
   public String getPreferredUsername() {
     return getProperty("preferredUsername");
   }
   
-  public void setPreferredUsername(String val) {
-    setProperty("preferredUsername", val);
-  }
-  
   public IRI getProfileUrl() {
     return getProperty("profileUrl");
   }
   
-  public void setProfileUrl(IRI iri) {
-    setProperty("profileUrl", iri);
-  }
-  
-  public void setProfileUrl(String iri) {
-    setProfileUrl(new IRI(iri));
-  }
-  
   public String getStatus() {
     return getProperty("status");
   }
   
-  public void setStatus(String status) {
-    setProperty("status", status);
-  }
-  
   public IRI getThumbnailUrl() {
     return getProperty("thumbnailUrl");
   }
   
-  public void setThumbnailUrl(IRI iri) {
-    setProperty("thumbnailUrl", iri);
-  }
-  
-  public void setThumbnailUrl(String iri) {
-    setThumbnailUrl(new IRI(iri));
-  }
-  
   public String getUtcOffset() {
     return getProperty("utcOffset");
   }
   
-  public void setUtcOffset(String val) {
-    setProperty("utfOffset",val);
-  }
-  
   public NameObject getName() {
     return getProperty("name");
   }
   
-  public void setName(NameObject name) {
-    setProperty("name", name);
-  }
-  
   public NameObject getNativeName() {
     return getProperty("nativeName");
   }
   
-  public void setNativeName(NameObject name) {
-    setProperty("nativeName", name);
-  }
-  
   public NameObject getPreferredName() {
     return getProperty("preferredName");
   }
   
-  public void setPreferredName(NameObject name) {
-    setProperty("preferredName", name);
-  }
-  
   public Iterable<NameObject> getAlternateNames() {
-    return getProperty("alternateNames");
-  }
-  
-  public void setAlternateNames(Set<NameObject> set) {
-    setProperty("alternateNames", set);
-  }
-  
-  public void addAlternateName(NameObject name) {
-    Set<NameObject> list = getProperty("alternateNames");
-    if (list == null) {
-      list = new HashSet<NameObject>();
-      setProperty("alternateNames",list);
-    }
-    list.add(name);
+    return checkEmpty(this.<Iterable<NameObject>>getProperty("alternateNames"));
   }
   
   public Iterable<String> getEmails() {
-    return getProperty("emails");
-  }
-  
-  public void setEmails(Set<String> set) {
-    setProperty("emails", set);
-  }
-  
-  public void addEmail(String email) {
-    Set<String> list = getProperty("email");
-    if (list == null) {
-      list = new HashSet<String>();
-      setProperty("emails",list);
-    }
-    list.add(email);
+    return checkEmpty(this.<Iterable<String>>getProperty("emails"));
   }
   
   public Iterable<String> getIms() {
-    return getProperty("ims");
-  }
-  
-  public void setIms(Set<String> set) {
-    setProperty("ims", set);
-  }
-  
-  public void addIm(String im) {
-    Set<String> list = getProperty("ims");
-    if (list == null) {
-      list = new HashSet<String>();
-      setProperty("ims",list);
-    }
-    list.add(im);
+    return checkEmpty(this.<Iterable<String>>getProperty("ims"));
   }
   
   public Iterable<String> getPhoneNumbers() {
-    return getProperty("phoneNumbers");
-  }
-  
-  public void setPhoneNumbers(Set<String> set) {
-    setProperty("phoneNumbers", set);
-  }
-  
-  public void addPhoneNumber(String phoneNumber) {
-    Set<String> list = getProperty("phoneNumbers");
-    if (list == null) {
-      list = new HashSet<String>();
-      setProperty("phoneNumbers",list);
-    }
-    list.add(phoneNumber);
+    return checkEmpty(this.<Iterable<String>>getProperty("phoneNumbers"));
   }
   
   public Iterable<IRI> getUrls() {
-    return getProperty("urls");
-  }
-  
-  public void setUrls(Set<IRI> set) {
-    setProperty("urls", set);
-  }
-  
-  public void addUrl(IRI url) {
-    Set<IRI> list = getProperty("urls");
-    if (list == null) {
-      list = new HashSet<IRI>();
-      setProperty("urls",list);
-    }
-    list.add(url);
-  }
-  
-  public void addUrl(String url) {
-    addUrl(new IRI(url));
+    return checkEmpty(this.<Iterable<IRI>>getProperty("urls"));
   }
   
   public Iterable<Address> getAddresses() {
-    return getProperty("addresses");
-  }
-  
-  public void setAddresses(Set<Address> set) {
-    setProperty("addresses", set);
-  }
-  
-  public void addAddress(Address address) {
-    Set<Address> list = getProperty("addresses");
-    if (list == null) {
-      list = new HashSet<Address>();
-      setProperty("addresses",list);
-    }
-    list.add(address);
+    return checkEmpty(this.<Iterable<Address>>getProperty("addresses"));
   }
   
   public Iterable<AccountObject> getAccounts() {
-    return getProperty("accounts");
-  }
-  
-  public void setAccounts(Set<AccountObject> set) {
-    setProperty("accounts", set);
-  }
-  
-  public void addAccount(AccountObject service) {
-    Set<ServiceObject> list = getProperty("accounts");
-    if (list == null) {
-      list = new HashSet<ServiceObject>();
-      setProperty("accounts",list);
-    }
-    list.add(service);
+    return checkEmpty(this.<Iterable<AccountObject>>getProperty("accounts"));
   }
   
   public Iterable<OrganizationObject> getOrganizations() {
-    return getProperty("organizations");
+    return checkEmpty(this.<Iterable<OrganizationObject>>getProperty("organizations"));
   }
   
-  public void setOrganizations(Set<OrganizationObject> set) {
-    setProperty("organizations", set);
+  public static PersonBuilder makePerson() {
+    return new PersonBuilder("person");
   }
   
-  public void addOrganization(OrganizationObject org) {
-    Set<OrganizationObject> list = getProperty("organizations");
-    if (list == null) {
-      list = new HashSet<OrganizationObject>();
-      setProperty("organizations",list);
+  public static PersonBuilder makePerson(String displayName) {
+    return makePerson().displayName(displayName);
+  }
+  
+  @Name("person")
+  @Properties({
+    @Property(name="profileUrl",to=IRI.class),
+    @Property(name="thumbnailUrl",to=IRI.class),
+    @Property(name="urls",to=IRI.class),
+    @Property(name="name",to=NameObject.class),
+    @Property(name="preferredName",to=NameObject.class),
+    @Property(name="nativeName",to=NameObject.class),
+    @Property(name="alternateNames",to=NameObject.class),
+    @Property(name="accounts",to=AccountObject.class),
+    @Property(name="addresses",to=Address.class),
+    @Property(name="organizations",to=OrganizationObject.class)
+  })
+  public static final class PersonBuilder extends Builder<PersonObject,PersonBuilder> {
+
+    public PersonBuilder() {
+      super(PersonObject.class, PersonBuilder.class);
     }
-    list.add(org);
-  }
-  
-  public static <T extends PersonObject>PersonObjectGenerator<T> makePerson() {
-    return new PersonObjectGenerator<T>();
+
+    public PersonBuilder(Map<String, Object> map) {
+      super(map, PersonObject.class, PersonBuilder.class);
+    }
+
+    public PersonBuilder(String objectType) {
+      super(objectType, PersonObject.class, PersonBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class PersonObjectGenerator<T extends PersonObject> extends ASObjectGenerator<T> {
-    public PersonObjectGenerator() {
-      super((Class<T>)PersonObject.class);
-    }
-    public PersonObjectGenerator(Class<? extends T> _class) {
-      super(_class);
-    }
-    public <X extends PersonObjectGenerator<T>>X account(AccountObject object) {
-      item.addAccount(object);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X address(Address object) {
-      item.addAddress(object);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X alternateName(NameObject name) {
-      item.addAlternateName(name);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X email(String email) {
-      item.addEmail(email);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X im(String im) {
-      item.addIm(im);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X organization(OrganizationObject object) {
-      item.addOrganization(object);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X phoneNumber(String pn) {
-      item.addPhoneNumber(pn);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X urls(String url) {
-      item.addUrl(url);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X urls(IRI url) {
-      item.addUrl(url);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X aboutMe(String val) {
-      item.setAboutMe(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X contactPreference(String val) {
-      item.setContactPreference(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X dn(String val) {
-      item.setDn(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X name(NameObject val) {
-      item.setName(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X nativeName(NameObject val) {
-      item.setNativeName(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X preferredName(NameObject val) {
-      item.setPreferredName(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X profileUrl(String val) {
-      item.setProfileUrl(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X profileUrl(IRI val) {
-      item.setProfileUrl(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X status(String val) {
-      item.setStatus(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X thumbnailUrl(String val) {
-      item.setThumbnailUrl(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X thumbnailUrl(IRI val) {
-      item.setThumbnailUrl(val);
-      return (X)this;
-    }
-    public <X extends PersonObjectGenerator<T>>X utcOffset(String val) {
-      item.setUtcOffset(val);
-      return (X)this;
+  public static class Builder<X extends PersonObject, M extends Builder<X,M>>
+    extends ASObject.Builder<X,M> {
+    private final ImmutableSet.Builder<AccountObject> accounts = ImmutableSet.builder();
+    private final ImmutableSet.Builder<Address> addresses = ImmutableSet.builder();
+    private final ImmutableSet.Builder<NameObject> altnames = ImmutableSet.builder();
+    private final ImmutableSet.Builder<String> emails = ImmutableSet.builder();
+    private final ImmutableSet.Builder<String> ims = ImmutableSet.builder();
+    private final ImmutableSet.Builder<OrganizationObject> orgs = ImmutableSet.builder();
+    private final ImmutableSet.Builder<String> phones = ImmutableSet.builder();
+    private final ImmutableSet.Builder<IRI> urls = ImmutableSet.builder();
+    boolean a,b,c,d,e,f,g,h;
+    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 account(AccountObject object) {
+      if (object == null) return (M)this;
+      a = true;
+      accounts.add(object);
+      return (M)this;
+    }
+    public M account(AccountObject... objects) {
+      if (objects.length == 0) return (M)this;
+      for (AccountObject object : objects)
+        account(object);
+      return (M)this;
+    }
+    public M account(Iterable<AccountObject> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (AccountObject object : objects)
+        account(object);
+      return (M)this;
+    }
+    public M address(Address object) {
+      if (object == null) return (M)this;
+      b = true;
+      addresses.add(object);
+      return (M)this;
+    }
+    public M address(Address... objects) {
+      if (objects.length == 0) return (M)this;
+      for (Address object : objects)
+        address(object);
+      return (M)this;
+    }
+    public M address(Iterable<Address> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (Address object : objects)
+        address(object);
+      return (M)this;
+    }
+    public M alternateName(NameObject name) {
+      if (name == null) return (M)this;
+      c = true;
+      altnames.add(name);
+      return (M)this;
+    }
+    public M alternateName(NameObject... objects) {
+      if (objects.length == 0) return (M)this;
+      for (NameObject object : objects)
+        alternateName(object);
+      return (M)this;
+    }
+    public M alternateName(Iterable<NameObject> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (NameObject object : objects)
+        alternateName(object);
+      return (M)this;
+    }
+    public M email(String email) {
+      if (email == null) return (M)this;
+      d = true;
+      emails.add(email);
+      return (M)this;
+    }
+    public M email(String... objects) {
+      if (objects.length == 0) return (M)this;
+      for (String object : objects)
+        email(object);
+      return (M)this;
+    }
+    public M email(Iterable<String> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (String object : objects)
+        email(object);
+      return (M)this;
+    }
+    public M im(String im) {
+      if (im == null) return (M)this;
+      e = true;
+      ims.add(im);
+      return (M)this;
+    }
+    public M im(String... objects) {
+      if (objects.length == 0) return (M)this;
+      for (String object : objects)
+        im(object);
+      return (M)this;
+    }
+    public M im(Iterable<String> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (String object : objects)
+        im(object);
+      return (M)this;
+    }
+    public M organization(OrganizationObject object) {
+      if (object == null) return (M)this;
+      f = true;
+      orgs.add(object);
+      return (M)this;
+    }
+    public M organization(OrganizationObject... objects) {
+      if (objects.length == 0) return (M)this;
+      for (OrganizationObject object : objects)
+        organization(object);
+      return (M)this;
+    }
+    public M organization(Iterable<OrganizationObject> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (OrganizationObject object : objects)
+        organization(object);
+      return (M)this;
+    }
+    public M phoneNumber(String pn) {
+      if (pn == null) return (M)this;
+      g = true;
+      phones.add(pn);
+      return (M)this;
+    }
+    public M phoneNumber(String... objects) {
+      if (objects.length == 0) return (M)this;
+      for (String object : objects)
+        phoneNumber(object);
+      return (M)this;
+    }
+    public M phoneNumber(Iterable<String> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (String object : objects)
+        phoneNumber(object);
+      return (M)this;
+    }
+    public M urls(String url) {
+      if (url == null) return (M)this;
+      return urls(new IRI(url));
+    }
+    public M urls(String... objects) {
+      if (objects.length == 0) return (M)this;
+      for (String object : objects)
+        urls(object);
+      return (M)this;
+    }
+    public M urls(Iterable<Object> objects) {
+      if (Iterables.isEmpty(objects)) return (M)this;
+      for (Object object : objects)
+        urls(object.toString());
+      return (M)this;
+    }
+    public M urls(IRI url) {
+      if (url == null) return (M)this;
+      h = true;
+      urls.add(url);
+      return (M)this;
+    }
+    public M urls(IRI... objects) {
+      if (objects.length == 0) return (M)this;
+      for (IRI object : objects)
+        urls(object);
+      return (M)this;
+    }
+    public M aboutMe(String val) {
+      set("aboutMe",val);
+      return (M)this;
+    }
+    public M contactPreference(String val) {
+      set("contactPreference",val);
+      return (M)this;
+    }
+    public M dn(String val) {
+      set("dn",val);
+      return (M)this;
+    }
+    public M name(NameObject val) {
+      set("name",val);
+      return (M)this;
+    }
+    public M nativeName(NameObject val) {
+      set("nativeName",val);
+      return (M)this;
+    }
+    public M preferredName(NameObject val) {
+      set("preferredName",val);
+      return (M)this;
+    }
+    public M profileUrl(String val) {
+      return profileUrl(new IRI(val));
+    }
+    public M profileUrl(IRI val) {
+      set("profileUrl",val);
+      return (M)this;
+    }
+    public M status(String val) {
+      set("status",val);
+      return (M)this;
+    }
+    public M thumbnailUrl(String val) {
+      return thumbnailUrl(new IRI(val));
+    }
+    public M thumbnailUrl(IRI val) {
+      set("thumbnailUrl",val);
+      return (M)this;
+    }
+    public M utcOffset(String val) {
+      set("utcOffset",val);
+      return (M)this;
+    }
+    public void preGet() {
+      if (a) set("accounts",accounts.build());
+      if (b) set("addresses",addresses.build());
+      if (c) set("alternateNames",altnames.build());
+      if (d) set("emails",emails.build());
+      if (e) set("ims",ims.build());
+      if (f) set("organizations",orgs.build());
+      if (g) set("phoneNumbers",phones.build());
+      if (h) set("urls",urls.build());
     }
+    
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PlaceObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PlaceObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PlaceObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/PlaceObject.java Thu Nov 10 21:48:45 2011
@@ -17,58 +17,108 @@
  */
 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.geo.Coordinate;
+import org.apache.abdera2.common.geo.IsoPosition;
+import org.apache.abdera2.common.geo.Point;
 
-@Name("place")
 public class PlaceObject 
   extends ASObject {
-
-  private static final long serialVersionUID = -8556845441567764050L;
-  public static final String POSITION = "position";
   public static final String ADDRESS = "address";
+  public static final String POSITION = "position";
   
-  public PlaceObject() {}
-  
-  public PlaceObject(String displayName) {
-    setDisplayName(displayName);
+  public PlaceObject(Map<String,Object> map) {
+    super(map,PlaceBuilder.class,PlaceObject.class);
   }
   
-  public String getPosition() {
-    return getProperty(POSITION);
+  public <X extends PlaceObject, M extends Builder<X,M>>PlaceObject(Map<String,Object> map, Class<M> _class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
-  public void setPosition(String position) {
-    setProperty(POSITION, position);
+  public IsoPosition getPosition() {
+    return getProperty(POSITION);
   }
   
   public Address getAddress() {
     return getProperty(ADDRESS);
   }
   
-  public void setAddress(Address address) {
-    setProperty(ADDRESS, address);
+  public static PlaceBuilder makePlace() {
+    return new PlaceBuilder("place");
+  }
+  
+  public static PlaceObject makePlace(String displayName) {
+    return makePlace().displayName(displayName).get();
+  }
+  
+  public static PlaceObject makePlace(String displayName, double latitude, double longitude) {
+    return makePlace().displayName(displayName).position(latitude,longitude).get();
+  }
+  
+  public static PlaceObject makePlace(String displayName, Coordinate coord) {
+    return makePlace().displayName(displayName).position(coord).get();
+  }
+  
+  public static PlaceObject makePlace(String displayName, Point point) {
+    return makePlace().displayName(displayName).position(point).get();
+  }
+  
+  public static PlaceObject makePlace(String displayName, IsoPosition position) {
+    return makePlace().displayName(displayName).position(position).get();
+  }
+  
+  public static PlaceObject makePlace(String displayName, Address address) {
+    return makePlace().displayName(displayName).address(address).get();
   }
+  
+  @Name("place")
+  public static final class PlaceBuilder extends Builder<PlaceObject,PlaceBuilder> {
+
+    public PlaceBuilder() {
+      super(PlaceObject.class,PlaceBuilder.class);
+    }
+
+    public PlaceBuilder(Map<String, Object> map) {
+      super(map, PlaceObject.class,PlaceBuilder.class);
+    }
 
-  public static <T extends PlaceObject>PlaceObjectGenerator<T> makePlace() {
-    return new PlaceObjectGenerator<T>();
+    public PlaceBuilder(String objectType) {
+      super(objectType, PlaceObject.class,PlaceBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class PlaceObjectGenerator<T extends PlaceObject> extends ASObjectGenerator<T> {
-    public PlaceObjectGenerator() {
-      super((Class<? extends T>) PlaceObject.class);
-    }
-    public PlaceObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends PlaceObjectGenerator<T>>X position(String position) {
-      item.setPosition(position);
-      return (X)this;
-    }
-    public <X extends PlaceObjectGenerator<T>>X address(Address address) {
-      item.setAddress(address);
-      return (X)this;
+  public static abstract class Builder<X extends PlaceObject, 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 position(IsoPosition position) {
+      set(POSITION,position);
+      return (M)this;
+    }
+    public M position(double latitude, double longitude) {
+      return position(IsoPosition.at(latitude, longitude));
+    }
+    public M position(Coordinate coord) {
+      return position(IsoPosition.at(coord));
+    }
+    public M position(Point point) {
+      return position(IsoPosition.at(point));
+    }
+    public M address(Address address) {
+      set(ADDRESS,address);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ProductObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ProductObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ProductObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ProductObject.java Thu Nov 10 21:48:45 2011
@@ -17,46 +17,64 @@
  */
 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("product")
 public class ProductObject 
   extends ASObject {
-
-  private static final long serialVersionUID = 8485599939786580223L;
   public static final String FULLIMAGE = "fullImage";
   
-  public ProductObject() {}
+  public ProductObject(Map<String,Object> map) {
+    super(map,ProductBuilder.class,ProductObject.class);
+  }
   
-  public ProductObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends ProductObject, M extends Builder<X,M>>ProductObject(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 ProductBuilder makeProduct() {
+    return new ProductBuilder("product");
   }
+  
+  @Name("product")
+  public static final class ProductBuilder extends Builder<ProductObject,ProductBuilder> {
+
+    public ProductBuilder() {
+      super(ProductObject.class,ProductBuilder.class);
+    }
+
+    public ProductBuilder(Map<String, Object> map) {
+      super(map, ProductObject.class,ProductBuilder.class);
+    }
 
-  public static <T extends ProductObject>ProductObjectGenerator<T> makeProduct() {
-    return new ProductObjectGenerator<T>();
+    public ProductBuilder(String objectType) {
+      super(objectType, ProductObject.class,ProductBuilder.class);
+    }
+    
   }
   
   @SuppressWarnings("unchecked")
-  public static class ProductObjectGenerator<T extends ProductObject> extends ASObjectGenerator<T> {
-    public ProductObjectGenerator() {
-      super((Class<? extends T>) ProductObject.class);
-    }
-    public ProductObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends ProductObjectGenerator<T>>X fullImage(MediaLink fullImage) {
-      item.setFullImage(fullImage);
-      return (X)this;
+  public static abstract class Builder<X extends ProductObject, 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/QuestionObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/QuestionObject.java Thu Nov 10 21:48:45 2011
@@ -17,59 +17,113 @@
  */
 package org.apache.abdera2.activities.model.objects;
 
-import java.util.HashSet;
-import java.util.Set;
+import java.util.Map;
 
 import org.apache.abdera2.activities.model.ASObject;
 import org.apache.abdera2.common.anno.Name;
 
-@Name("question")
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Iterables;
+
 public class QuestionObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -691354277218118929L;
   public static final String OPTIONS = "options";
   
-  public QuestionObject() {}
-
-  public QuestionObject(String displayName) {
-    setDisplayName(displayName);
+  public QuestionObject(Map<String,Object> map) {
+    super(map,QuestionBuilder.class,QuestionObject.class);
+  }
+  
+  public <X extends QuestionObject, M extends Builder<X,M>>QuestionObject(Map<String,Object> map, Class<M> _class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   public Iterable<ASObject> getOptions() {
     return getProperty(OPTIONS);
   }
   
-  public void setOptions(Set<ASObject> options) {
-    setProperty(OPTIONS, options);
-    
+  public static QuestionBuilder makeQuestion() {
+    return new QuestionBuilder("question");
   }
   
-  public void addOption(ASObject option) {
-    Set<ASObject> list = getProperty(OPTIONS);
-    if (list == null) {
-      list = new HashSet<ASObject>();
-      setProperty(OPTIONS, list);
-    }
-    list.add(option); 
+  public static QuestionObject makeQuestion(
+    String displayName,
+    String summary, 
+    ASObject author,
+    ASObject... options) {
+    return makeQuestion()
+      .displayName(displayName)
+      .summary(summary)
+      .author(author)
+      .option(options).get();
   }
   
-  public static <T extends QuestionObject>QuestionObjectGenerator<T> makeQuestion() {
-    return new QuestionObjectGenerator<T>();
+  public static QuestionObject makeQuestion(
+    String displayName,
+    String summary, 
+    ASObject author,
+    Iterable<ASObject> options) {
+    return makeQuestion()
+      .displayName(displayName)
+      .summary(summary)
+      .author(author)
+      .option(options).get();
   }
 
+  @Name("question")
+  public static final class QuestionBuilder extends Builder<QuestionObject,QuestionBuilder> {
+
+    public QuestionBuilder() {
+      super(QuestionObject.class,QuestionBuilder.class);
+    }
+
+    public QuestionBuilder(Map<String, Object> map) {
+      super(map,QuestionObject.class,QuestionBuilder.class);
+    }
+
+    public QuestionBuilder(String objectType) {
+      super(objectType,QuestionObject.class,QuestionBuilder.class);
+    }
+    
+  }
+  
   @SuppressWarnings("unchecked")
-  public static class QuestionObjectGenerator<T extends QuestionObject> 
-    extends ASObjectGenerator<T> {
-    public QuestionObjectGenerator() {
-      super((Class<? extends T>) QuestionObject.class);
-    }
-    public QuestionObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends QuestionObjectGenerator<T>>X option(ASObject object) {
-      item.addOption(object);
-      return (X)this;
+  public static abstract class Builder <X extends QuestionObject, M extends Builder<X,M>>
+    extends ASObject.Builder<X,M> {
+    
+    private ImmutableSet.Builder<ASObject> options = 
+      ImmutableSet.builder();
+    boolean a;
+    
+    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 option(Iterable<ASObject> options) {
+      if (Iterables.isEmpty(options)) return (M)this;
+      for (ASObject option : options)
+        option(option);
+      return (M)this;
+    }
+    public M option(ASObject... options) {
+      if (options.length == 0) return (M)this;
+      for (ASObject option : options)
+        option(option);
+      return (M)this;
+    }
+    public M option(ASObject object) {
+      if (object == null) return (M)this;
+      a = true;
+      options.add(object);
+      return (M)this;
+    }
+    public void preGet() {
+      if (a) set(OPTIONS, options.build());
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ReviewObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ReviewObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ReviewObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ReviewObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,40 @@
  */
 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("review")
 public class ReviewObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -6860912447124744192L;
-  
-  public ReviewObject() {}
   
-  public ReviewObject(String displayName) {
-    setDisplayName(displayName);
+  public static <T extends ReviewObject>Builder makeReview() {
+    return new Builder("review");
+  }
+  @Name("review")
+  public static final class Builder 
+    extends ASObject.Builder<ReviewObject,Builder> {
+    public Builder(String objectType) {
+      super(objectType,ReviewObject.class,Builder.class);
+    }
+    public Builder() {
+      super(ReviewObject.class,Builder.class);
+    }
+    public Builder(Map<String,Object> map) {
+      super(map,ReviewObject.class,Builder.class);
+    }
+    public Builder template() {
+      return new Builder(map.build());
+    }
   }
   
-  public static <T extends ReviewObject>ReviewObjectGenerator<T> makeReview() {
-    return new ReviewObjectGenerator<T>();
+  public ReviewObject(Map<String,Object> map) {
+    super(map,Builder.class,ReviewObject.class);
   }
   
-  public static class ReviewObjectGenerator<T extends ReviewObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public ReviewObjectGenerator() {
-      super((Class<? extends T>) ReviewObject.class);
-    }
-    public ReviewObjectGenerator(Class<? extends T> _class) {
-      super(_class);
-    }
+  public <X extends ReviewObject, M extends ASObject.Builder<X,M>>ReviewObject(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/ServiceObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ServiceObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ServiceObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/ServiceObject.java Thu Nov 10 21:48:45 2011
@@ -17,32 +17,40 @@
  */
 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("service")
+
 public class ServiceObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -2801393062155634922L;
-  
-  public ServiceObject() {}
   
-  public ServiceObject(String displayName) {
-    setDisplayName(displayName);
-  }  
-  
-  public static <T extends ServiceObject>ServiceObjectGenerator<T> makeService() {
-    return new ServiceObjectGenerator<T>();
+  public static Builder makeService() {
+    return new Builder("service");
   }
   
-  public static class ServiceObjectGenerator<T extends ServiceObject> extends ASObjectGenerator<T> {
-    @SuppressWarnings("unchecked")
-    public ServiceObjectGenerator() {
-      super((Class<? extends T>) ServiceObject.class);
+  @Name("service")
+  public final static class Builder 
+    extends ASObject.Builder<ServiceObject,Builder> {
+    public Builder() {
+      super(ServiceObject.class,Builder.class);
+    }
+    public Builder(String objectType) {
+      super(objectType,ServiceObject.class,Builder.class);
     }
-    public ServiceObjectGenerator(Class<? extends T> _class) {
-      super(_class);
+    public Builder(Map<String,Object> map) {
+      super(map,ServiceObject.class,Builder.class);
     }
   }
+  
+  protected ServiceObject(Map<String,Object> map) {
+    super(map,Builder.class,ServiceObject.class);
+  }
+  
+  protected <X extends ServiceObject, M extends ASObject.Builder<X,M>>ServiceObject(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/TvEpisodeObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvEpisodeObject.java Thu Nov 10 21:48:45 2011
@@ -1,10 +1,11 @@
 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.activities.model.MediaLink;
-import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 
@@ -12,153 +13,133 @@ import org.joda.time.DateTime;
  * A simple "objectType":"tv-episode" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("tv-episode")
-@Properties({
-  @Property(name="preview",to=MediaLink.class),
-  @Property(name="aired",to=DateTime.class)
-})
 @SuppressWarnings("unchecked")
 public class TvEpisodeObject extends CreativeWork {
 
-  private static final long serialVersionUID = -1551754630697817614L;
-
-  public TvEpisodeObject() {}
+  public TvEpisodeObject(Map<String,Object> map) {
+    super(map,TvEpisodeBuilder.class,TvEpisodeObject.class);
+  }
   
-  public TvEpisodeObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends TvEpisodeObject, M extends Builder<X,M>>TvEpisodeObject(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 <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 DateTime getAired() {
     return getProperty("aired");
   }
   
-  public void setAired(DateTime dt) {
-    setProperty("aired",dt);
-  }
-  
   public MediaLink getPreview() {
     return getProperty("preview");
   }
   
-  public void setPreview(MediaLink link) {
-    setProperty("preview", link);
-  }
-  
   public <T extends ASObject>T getSeries() {
     return (T)getProperty("series");
   }
   
-  public void setSeries(ASObject series) {
-    setProperty("series", series);
-  }
-  
   public <T extends ASObject>T getSeason() {
     return (T)getProperty("season");
   }
   
-  public void setSeason(ASObject season) {
-    setProperty("season", season);
-  }
-  
   public int getEpisodeNumber() {
-    return (Integer)getProperty("episode");
+    return getPropertyInt("episode");
   }
   
-  public void setEpisodeNumber(int episode) {
-    setProperty("episode", episode);
-  }
   
+  public static TvEpisodeBuilder makeTvEpisode() {
+    return new TvEpisodeBuilder("tv-episode");
+  }
   
-  public static <T extends TvEpisodeObject>TvEpisodeObjectGenerator<T> makeTvEpisode() {
-    return new TvEpisodeObjectGenerator<T>();
+  @Name("tv-episode")
+  @Properties({
+    @Property(name="preview",to=MediaLink.class),
+    @Property(name="aired",to=DateTime.class)
+  })
+  public static final class TvEpisodeBuilder extends Builder<TvEpisodeObject,TvEpisodeBuilder> {
+
+    public TvEpisodeBuilder() {
+      super(TvEpisodeObject.class,TvEpisodeBuilder.class);
+    }
+
+    public TvEpisodeBuilder(Map<String, Object> map) {
+      super(map, TvEpisodeObject.class,TvEpisodeBuilder.class);
+    }
+
+    public TvEpisodeBuilder(String objectType) {
+      super(objectType, TvEpisodeObject.class,TvEpisodeBuilder.class);
+    }
+    
   }
   
-  public static class TvEpisodeObjectGenerator<T extends TvEpisodeObject> extends CreativeWorkGenerator<T> {
-    public TvEpisodeObjectGenerator() {
-      super((Class<T>) TvEpisodeObject.class);
+  public static abstract class Builder<X extends TvEpisodeObject, M extends Builder<X,M>>
+    extends CreativeWork.Builder<X,M> {
+    protected Builder(Class<X>_class,Class<M>_builder) {
+      super(_class,_builder);
     }
-    public TvEpisodeObjectGenerator(Class<T> _class) {
-      super(_class);
+    protected Builder(String objectType,Class<X>_class,Class<M>_builder) {
+      super(objectType,_class,_builder);
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X actors(ASObject obj) {
-      item.setActors(obj);
-      return (X)this;
+    protected Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X director(ASObject obj) {
-      item.setDirector(obj);
-      return (X)this;
+    public M actors(ASObject obj) {
+      set("actors",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X episodeNumber(int n) {
-      item.setEpisodeNumber(n);
-      return (X)this;
+    public M director(ASObject obj) {
+      set("director",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X season(ASObject obj) {
-      item.setSeason(obj);
-      return (X)this;
+    public M episodeNumber(int n) {
+      set("episodeNumber",n);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X series(ASObject obj) {
-      item.setSeries(obj);
-      return (X)this;
+    public M season(ASObject obj) {
+      set("season",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X musicBy(ASObject obj) {
-      item.setMusicBy(obj);
-      return (X)this;
+    public M series(ASObject obj) {
+      set("series",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X preview(MediaLink obj) {
-      item.setPreview(obj);
-      return (X)this;
+    public M musicBy(ASObject obj) {
+      set("musicBy",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X producer(ASObject obj) {
-      item.setProducer(obj);
-      return (X)this;
+    public M preview(MediaLink obj) {
+      set("preview",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X productionCompany(ASObject obj) {
-      item.setProductionCompany(obj);
-      return (X)this;
+    public M producer(ASObject obj) {
+      set("producer",obj);
+      return (M)this;
     }
-    public <X extends TvEpisodeObjectGenerator<T>>X aired(DateTime dateTime) {
-      item.setAired(dateTime);
-      return (X)this;
+    public M productionCompany(ASObject obj) {
+      set("productionCompany",obj);
+      return (M)this;
     }
+    public M aired(DateTime dateTime) {
+      set("aired",dateTime);
+      return (M)this;
+    }    
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeasonObject.java Thu Nov 10 21:48:45 2011
@@ -1,10 +1,11 @@
 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.activities.model.MediaLink;
-import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 
@@ -12,167 +13,141 @@ import org.joda.time.DateTime;
  * A simple "objectType":"tv-season" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("tv-season")
-@Properties({
-  @Property(name="startDate",to=DateTime.class),
-  @Property(name="endDate",to=DateTime.class),
-  @Property(name="preview",to=MediaLink.class)
-})
 @SuppressWarnings("unchecked")
 public class TvSeasonObject extends CreativeWork {
 
-  private static final long serialVersionUID = -1551754630697817614L;
-
-  public TvSeasonObject() {}
+  public TvSeasonObject(Map<String,Object> map) {
+    super(map,TvSeasonBuilder.class,TvSeasonObject.class);
+  }
   
-  public TvSeasonObject(String displayName) {
-    setDisplayName(displayName);
+  public <X extends TvSeasonObject, M extends Builder<X,M>>TvSeasonObject(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 object) {
-    setProperty("director", object);
-  }
-  
   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 DateTime getStartDate() {
     return getProperty("startDate");
   }
   
-  public void setStartDate(DateTime date) {
-    setProperty("startDate", date);
-  }
-  
   public DateTime getEndDate() {
     return getProperty("endDate");
   }
   
-  public void setEndDate(DateTime date) {
-    setProperty("endDate", date);
-  }
-  
   public <T extends ASObject>T getEpisodes() {
     return (T)getProperty("episodes");
   }
   
-  public void setEpisodes(ASObject episodes) {
-    setProperty("episodes", episodes);
-  }
-  
   public <T extends ASObject>T getSeries() {
     return (T)getProperty("series");
   }
   
-  public void setSeries(ASObject series) {
-    setProperty("series", series);
-  }
-  
   public int getSeasonNumber() {
-    return (Integer)getProperty("season");
+    return getPropertyInt("season");
   }
   
-  public void setSeasonNumber(int season) {
-    setProperty("season", season);
+  public static TvSeasonBuilder makeTvSeason() {
+    return new TvSeasonBuilder("tv-season");
   }
   
-  
-  
-  public static <T extends TvSeasonObject>TvSeasonObjectGenerator<T> makeTvSeason() {
-    return new TvSeasonObjectGenerator<T>();
+  @Name("tv-season")
+  @Properties({
+    @Property(name="startDate",to=DateTime.class),
+    @Property(name="endDate",to=DateTime.class),
+    @Property(name="preview",to=MediaLink.class)
+  })
+    public static final class TvSeasonBuilder extends Builder<TvSeasonObject,TvSeasonBuilder> {
+
+    public TvSeasonBuilder() {
+      super(TvSeasonObject.class,TvSeasonBuilder.class);
+    }
+
+    public TvSeasonBuilder(Map<String, Object> map) {
+      super(map, TvSeasonObject.class,TvSeasonBuilder.class);
+    }
+
+    public TvSeasonBuilder(String objectType) {
+      super(objectType, TvSeasonObject.class,TvSeasonBuilder.class);
+    }
+    
   }
   
-  public static class TvSeasonObjectGenerator<T extends TvSeasonObject> extends CreativeWorkGenerator<T> {
-    public TvSeasonObjectGenerator() {
-      super((Class<T>) TvSeasonObject.class);
+  public static abstract class Builder<X extends TvSeasonObject, M extends Builder<X,M>>
+    extends CreativeWork.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);
     }
-    public TvSeasonObjectGenerator(Class<T> _class) {
-      super(_class);
+    protected Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends TvSeasonObjectGenerator<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 TvSeasonObjectGenerator<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 TvSeasonObjectGenerator<T>>X seasonNumber(int n) {
-      item.setSeasonNumber(n);
-      return (X)this;
+    public M seasonNumber(int n) {
+      set("seasonNumber",n);
+      return (M)this;
     }
-    public <X extends TvSeasonObjectGenerator<T>>X series(ASObject obj) {
-      item.setSeries(obj);
-      return (X)this;
+    public M series(ASObject obj) {
+      set("series",obj);
+      return (M)this;
     }
-    public <X extends TvSeasonObjectGenerator<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 TvSeasonObjectGenerator<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 TvSeasonObjectGenerator<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 TvSeasonObjectGenerator<T>>X productionCompany(ASObject obj) {
-      item.setProductionCompany(obj);
-      return (X)this;
+    public M productionCompany(ASObject obj) {
+      set("productionCompany",obj);
+      return (M)this;
     }
-    public <X extends TvSeasonObjectGenerator<T>>X startDate(DateTime dt) {
-      item.setStartDate(dt);
-      return (X)this;
+    public M startDate(DateTime dt) {
+      set("startDate",dt);
+      return (M)this;
     }
-    public <X extends TvSeasonObjectGenerator<T>>X endDate(DateTime dt) {
-      item.setEndDate(dt);
-      return (X)this;
+    public M endDate(DateTime dt) {
+      set("endDate",dt);
+      return (M)this;
     }
-    public <X extends TvSeasonObjectGenerator<T>>X episodes(ASObject obj) {
-      item.setEpisodes(obj);
-      return (X)this;
+    public M episodes(ASObject obj) {
+      set("episodes",obj);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/TvSeriesObject.java Thu Nov 10 21:48:45 2011
@@ -1,10 +1,11 @@
 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.activities.model.MediaLink;
-import org.apache.abdera2.activities.model.objects.CreativeWork.CreativeWorkGenerator;
 import org.apache.abdera2.common.anno.Name;
 import org.joda.time.DateTime;
 
@@ -12,155 +13,134 @@ import org.joda.time.DateTime;
  * A simple "objectType":"tv-series" object that serves primarily as an 
  * example of creating new ASObject types.
  */
-@Name("tv-series")
-@Properties({
-  @Property(name="startDate",to=DateTime.class),
-  @Property(name="endDate",to=DateTime.class),
-  @Property(name="preview",to=MediaLink.class)
-})
 @SuppressWarnings("unchecked")
 public class TvSeriesObject extends CreativeWork {
 
-  private static final long serialVersionUID = -1551754630697817614L;
-
-  public TvSeriesObject() {}
-  
-  public TvSeriesObject(String displayName) {
-    setDisplayName(displayName);
+  public TvSeriesObject(Map<String,Object> map) {
+    super(map,TvSeriesBuilder.class,TvSeriesObject.class);
   }
   
+  public <X extends TvSeriesObject, M extends Builder<X,M>>TvSeriesObject(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 object) {
-    setProperty("director", object);
-  }
-
   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 DateTime getStartDate() {
     return getProperty("startDate");
   }
   
-  public void setStartDate(DateTime date) {
-    setProperty("startDate", date);
-  }
-  
   public DateTime getEndDate() {
     return getProperty("endDate");
   }
   
-  public void setEndDate(DateTime date) {
-    setProperty("endDate", date);
-  }
-  
   public <T extends ASObject>T getSeasons() {
     return (T)getProperty("seasons");
   }
   
-  public void setSeasons(ASObject seasons) {
-    setProperty("seasons", seasons);
-  }
-  
   public <T extends ASObject>T getEpisodes() {
     return (T)getProperty("episodes");
   }
   
-  public void setEpisodes(ASObject episodes) {
-    setProperty("episodes", episodes);
+    
+  public static TvSeriesBuilder makeTvSeries() {
+    return new TvSeriesBuilder("tv-series");
   }
   
-  
-  
-  public static <T extends TvSeriesObject>TvSeriesObjectGenerator<T> makeTvSeries() {
-    return new TvSeriesObjectGenerator<T>();
+  @Name("tv-series")
+  @Properties({
+    @Property(name="startDate",to=DateTime.class),
+    @Property(name="endDate",to=DateTime.class),
+    @Property(name="preview",to=MediaLink.class)
+  })
+  public static final class TvSeriesBuilder extends Builder<TvSeriesObject,TvSeriesBuilder> {
+
+    public TvSeriesBuilder() {
+      super(TvSeriesObject.class,TvSeriesBuilder.class);
+    }
+
+    public TvSeriesBuilder(Map<String, Object> map) {
+      super(map, TvSeriesObject.class,TvSeriesBuilder.class);
+    }
+
+    public TvSeriesBuilder(String objectType) {
+      super(objectType, TvSeriesObject.class,TvSeriesBuilder.class);
+    }
+    
   }
   
-  public static class TvSeriesObjectGenerator<T extends TvSeriesObject> extends CreativeWorkGenerator<T> {
-    public TvSeriesObjectGenerator() {
-      super((Class<T>) TvSeriesObject.class);
+  public static abstract class Builder<X extends TvSeriesObject, M extends Builder<X,M>>
+    extends CreativeWork.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);
     }
-    public TvSeriesObjectGenerator(Class<T> _class) {
-      super(_class);
+    protected Builder(Map<String,Object> map,Class<X>_class,Class<M>_builder) {
+      super(map,_class,_builder);
     }
-    public <X extends TvSeriesObjectGenerator<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 TvSeriesObjectGenerator<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 TvSeriesObjectGenerator<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 TvSeriesObjectGenerator<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 TvSeriesObjectGenerator<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 TvSeriesObjectGenerator<T>>X productionCompany(ASObject obj) {
-      item.setProductionCompany(obj);
-      return (X)this;
+    public M productionCompany(ASObject obj) {
+      set("productionCompany",obj);
+      return (M)this;
     }
-    public <X extends TvSeriesObjectGenerator<T>>X episodes(ASObject obj) {
-      item.setEpisodes(obj);
-      return (X)this;
+    public M episodes(ASObject obj) {
+      set("episodes",obj);
+      return (M)this;
     }
-    public <X extends TvSeriesObjectGenerator<T>>X seasons(ASObject obj) {
-      item.setSeasons(obj);
-      return (X)this;
+    public M seasons(ASObject obj) {
+      set("seasons",obj);
+      return (M)this;
     }
-    public <X extends TvSeriesObjectGenerator<T>>X startDate(DateTime dt) {
-      item.setStartDate(dt);
-      return (X)this;
+    public M startDate(DateTime dt) {
+      set("startDate",dt);
+      return (M)this;
     }
-    public <X extends TvSeriesObjectGenerator<T>>X endDate(DateTime dt) {
-      item.setEndDate(dt);
-      return (X)this;
+    public M endDate(DateTime dt) {
+      set("endDate",dt);
+      return (M)this;
     }
   }
 }

Modified: abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java
URL: http://svn.apache.org/viewvc/abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java?rev=1200583&r1=1200582&r2=1200583&view=diff
==============================================================================
--- abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java (original)
+++ abdera/abdera2/activities/src/main/java/org/apache/abdera2/activities/model/objects/VersionObject.java Thu Nov 10 21:48:45 2011
@@ -1,32 +1,134 @@
 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;
+import org.apache.abdera2.common.anno.Version;
 
 /**
  * Activity Stream object that represents a description of a Version 
  * of a referenced object. "objectType":"version"... The basic use 
  * case for this would be for Version control systems.
  */
-@Name("version")
-@Properties({
-  @Property(name="previousVersion", to=VersionObject.class),
-  @Property(name="nextVersion",to=VersionObject.class),
-  @Property(name="stableVersion",to=VersionObject.class),
-  @Property(name="activeVersion",to=VersionObject.class)
-})
 public class VersionObject 
   extends ASObject {
 
-  private static final long serialVersionUID = -7473463819890471971L;
+  public static VersionBuilder makeVersion() {
+    return new VersionBuilder("version");
+  }
+  
+  public static VersionObject makeVersion(
+    ASObject of, 
+    int major, 
+    int minor, 
+    int revision,
+    Version.Status status) {
+    return makeVersion()
+      .of(of)
+      .major(major)
+      .minor(minor)
+      .revision(revision)
+      .status(status)
+      .get();
+  }
+  
+  public static VersionObject makeVersion(Version version) {
+    return makeVersion()
+      .of(
+        ASObject.makeObject()
+          .displayName(version.name())
+          .url(version.uri())
+          .get())
+      .major(version.major())
+      .minor(version.minor())
+      .revision(version.revision())
+      .status(version.status())
+      .get();
+  }
+
+  @Name("version")
+  @Properties({
+    @Property(name="previousVersion", to=VersionObject.class),
+    @Property(name="nextVersion",to=VersionObject.class),
+    @Property(name="stableVersion",to=VersionObject.class),
+    @Property(name="activeVersion",to=VersionObject.class)
+  })
+  public static final class VersionBuilder extends Builder<VersionObject,VersionBuilder> {
+
+    public VersionBuilder() {
+      super(VersionObject.class,VersionBuilder.class);
+    }
+
+    public VersionBuilder(Map<String, Object> map) {
+      super(map, VersionObject.class,VersionBuilder.class);
+    }
+
+    public VersionBuilder(String objectType) {
+      super(objectType, VersionObject.class,VersionBuilder.class);
+    }
+    
+  }
+  
+  @SuppressWarnings("unchecked")
+  public static abstract class Builder<X extends VersionObject, 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 active(VersionObject object) {
+      set("activeVersion",object);
+      return (M)this;
+    }
+    public M major(int val) {
+      set("major",Math.max(0, val));
+      return (M)this;
+    }
+    public M minor(int val) {
+      set("minor",Math.max(0, val));
+      return (M)this;
+    }
+    public M revision(int val) {
+      set("revision",Math.max(0,val));
+      return (M)this;
+    }
+    public M status(Version.Status status) {
+      set("status",status.name().toLowerCase());
+      return (M)this;
+    }
+    public M next(VersionObject val) {
+      set("nextVersion",val);
+      return (M)this;
+    }
+    public M of(ASObject val) {
+      set("of",val);
+      return (M)this;
+    }
+    public M previous(VersionObject val) {
+      set("previousVersion",val);
+      return (M)this;
+    }
+    public M stable(VersionObject val) {
+      set("stableVersion",val);
+      return (M)this;
+    }
+  }
+  
 
-  public VersionObject() {}
+  public VersionObject(Map<String,Object> map) {
+    super(map,VersionBuilder.class,VersionObject.class);
+  }
   
-  public VersionObject(String displayName) {
-    super();
-    setDisplayName(displayName);
+  public <X extends VersionObject, M extends Builder<X,M>>VersionObject(Map<String,Object> map,Class<M>_class,Class<X>_obj) {
+    super(map,_class,_obj);
   }
   
   /** The object this object describes a version of **/
@@ -34,111 +136,38 @@ public class VersionObject 
   public <T extends ASObject>T getOf() {
     return (T)getProperty("of");
   }
-  
-  /** The object this object describes a version of **/
-  public void setOf(ASObject object) {
-    setProperty("of", object);
-  }
-  
+    
   public VersionObject getPreviousVersion() {
     return getProperty("previousVersion");
   }
   
-  public void setPreviousVersion(VersionObject version) {
-    setProperty("previousVersion", version);
-  }
-  
   public VersionObject getNextVersion() {
     return getProperty("nextVersion");
   }
   
-  public void setNextVersion(VersionObject version) {
-    setProperty("nextVersion", version);
-  }
-  
   public VersionObject getStableVersion() {
     return getProperty("stableVersion");
   }
   
-  public void setStableVersion(VersionObject version) {
-    setProperty("stableVersion", version);
-  }
-  
   public VersionObject getActiveVersion() {
     return getProperty("activeVersion");
   }
   
-  public void setActiveVersion(VersionObject version) {
-    setProperty("activeVersion", version);
-  }
-  
-  public String getMajor() {
-    return getProperty("major");
+  public int getMajor() {
+    return getPropertyInt("major");
   }
   
-  public void setMajor(String val) {
-    setProperty("major", val);
+  public int getMinor() {
+    return getPropertyInt("minor");
   }
   
-  public String getMinor() {
-    return getProperty("minor");
+  public int getRevision() {
+    return getPropertyInt("revision");
   }
   
-  public void setMinor(String minor) {
-    setProperty("minor", minor);
-  }
-  
-  public String getRevision() {
-    return getProperty("revision");
-  }
-  
-  public void setRevision(String val) {
-    setProperty("revision", val);
-  }
-  
-  public static <T extends VersionObject>VersionObjectGenerator<T> makeVersion() {
-    return new VersionObjectGenerator<T>();
-  }
-  
-  @SuppressWarnings("unchecked")
-  public static class VersionObjectGenerator<T extends VersionObject> extends ASObjectGenerator<T> {
-    public VersionObjectGenerator() {
-      super((Class<? extends T>) VersionObject.class);
-    }
-    public VersionObjectGenerator(Class<T> _class) {
-      super(_class);
-    }
-    public <X extends VersionObjectGenerator<T>>X active(VersionObject object) {
-      item.setActiveVersion(object);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X major(String val) {
-      item.setMajor(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X minor(String val) {
-      item.setMinor(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X next(VersionObject val) {
-      item.setNextVersion(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X of(ASObject val) {
-      item.setOf(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X previous(VersionObject val) {
-      item.setPreviousVersion(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X revision(String val) {
-      item.setRevision(val);
-      return (X)this;
-    }
-    public <X extends VersionObjectGenerator<T>>X stable(VersionObject val) {
-      item.setStableVersion(val);
-      return (X)this;
-    }
+  public Version.Status getStatus() {
+    String status = getProperty("status");
+    return status != null ?
+      Version.Status.valueOf(status.toUpperCase()) : null;
   }
 }



Mime
View raw message