MetaClass in Groovy

groovy.lang Interface MetaClass – A MetaClass within Groovy defines the behaviour of any given Groovy or Java class. The MetaClass interface defines two parts. The client API, which is defined via the extend MetaObjectProtocol interface and the contract with the Groovy runtime system. In general the compiler and Groovy runtime engine interact with methods on this class whilst MetaClass clients interact with the method defined by the MetaObjectProtocol interface.

This is the example how to use Groovy’s MetaClass:

[groovy]
class Individual {

String nationality
String title
String givenName
String middleName;=
String surname
String dob
String occupation

Individual() {}

Individual(def map) {
metaClass.setProperties(this, map.findAll { key, value -> this.hasProperty(key) })
}
}
[/groovy]

There is no getter and setter for a POJO object like class Individual. When you initialise it:

[groovy]
individual = new Individual(params.("applicant" + i))
[/groovy]

will match and set all the data in your submit form, with field name like:

applicant1.nationality
applicant1.title

applicant1.occupation

 

Deflating speculation on the property bubble

Home prices will halve over the next few years, says the only forecaster to have predicted both the record share market run to 2007 as well as the subsequent GFC. And that was in 1993.

More recently, he also predicted the property collapse in the US, selling his Florida home at the peak in 2005 and renting ever since.

He’s predicting a second big drop in the US and Australia’s first, which, in four years, could turn McMansions into ghost houses.

The chief economist at AMP Capital Investors, Shane Oliver, says prices are “way overvalued”, though not in a bubble. They need to correct by about 25 per cent but there are alternatives to a crash, such as a slow meltdown – or should that be a fast cool down? – or no movement for years as inflation, like termites, wrecks the foundations.

Hello world!

Welcome to WordPress.com. After you read this, you should delete and write your own post, with a new title above. Or hit Add New on the left (of the admin dashboard) to start a fresh post.

Here are some suggestions for your first post.

  1. You can find new ideas for what to blog about by reading the Daily Post.
  2. Add PressThis to your browser. It creates a new blog post for you about any interesting  page you read on the web.
  3. Make some changes to this page, and then hit preview on the right. You can always preview any post or edit it before you share it to the world.