If you are used to coding Android applications, there is a good chance that you had to write some Parcelable classes.

A quick reminder about Parcelable : It’s an interface you can implement on your classes. If you do so, you can then store the whole class in a Bundle or as an Intent extra.
My webservice library, DataDroid, use Parcelable objects to retrieve the result from the webservices if you don’t use a Database to store your data.

There is one downside with Parcelable … You need to write a LOT of boilerplate to implement the Parcelable interface in your class. And as every good software engineer, I’m lazy :D
Which brings us to ParcelableCodeGenerator !!

You can find all the information on its GitHub page, but here is a short explanation :

  • You clone the repository and import the Java project in Eclipse (or your favorite IDE)
  • You write a JSON file defining your Parcelable class in the input folder (you can use subfolders to sort your files). Examples are provided to learn the syntax
  • You run the project as a Java Project
  • The corresponding classes are “magically” generated in the output folder ready for you to copy them in your project

It’s really easy to use and it’s going to save you a lot of time.

Last important thing : the project license. As all my other projects, it is released under the Beerware license :

You can do whatever you want with this stuff. If we meet some day, and you think this stuff is worth it, you can buy me a beer in return.

Similar Posts:

  1. I use Datadroid a lot and have good experience with it. I also use ParcelableCodeGenerator, it helps in most cases. One thing can be improved is, for json format with array in array directly, ParcelableCodeGenerator didn’t support. I did create my own Parcelable class on my hand. But it still a great library. Thank you!

  2. Foxykeep (47 comments)

    Just sent you an email to get more information. Maybe I can change the ParcelableCodeGenerator to manage your case :)

Leave a Reply

Page optimized by WP Minify WordPress Plugin