easiest way is to use a hashmap instead of a class.you can dynamically genereate classes in Javabut if you like this kind of features it is better to use JRuby or Groovy.since java is a statically typed language.