I've been doing some playing around with the Abdera model APIs for Atom objects. Most things seem to go pretty well, but I stumble a bit with some inconsistencies in trying to use "builder pattern" style calls to configure many aspects of the objects at once.

For example, let's set up a new o.a.a.model.Collection instance. I'd like to be able to do something like this:

   Factory factory = Abdera.getInstance().getFactory();
   ...
   Collection customers = factory.newCollection()
     .setHref("...")
     .setAccept("application/atom+xml;type=entry")
     .setTitle("Customers List");

but this will fail, because setTitle (all the variants) returns a Text instead of the Collection you are manipulating, like all the other setXxx calls do.

There is similar inconsistency on Collection (and the pattern repeats itself with many of the other model objects) in the addXxx() methods. Consider the following APIs to add a Categories object to a Collection:

* addCategories() returns Categories

* addCategories(Categories categories) returns Collection

* addCategories(List<Category> categories, boolean fixed, String scheme) returns Categories

* addCategories(String href) returns Categories

For easiest possible builder pattern style development, it would be best if all these (except possibly the first one, but I wouldn't likely use that anyway) returned the Collection you were modifying.

Is there a reason I'm missing for the inconsistencies?

Craig

Reply via email to