Hi all,

one of the goal of BeanUtils2 is to provide the same functionality as
BeanUtils1. In BeanUtils1 you can do something like this:

BeanUtils.getProperty(person, "address.city.zipCode");

This would be translated into:

person.getAddress().getCity().getZipCode();

The same can be done with mapped and indexed properties:

BeanUtils.getProperty(person, "contact(5).name");

which would be translated to:

person.getContact(5).getName();

BeanUtils2 provides a fluent API where the first example would be done via:

on(person).get("address").get("city").get("zipCode")

and the second:

on(person).getIndexed("contact").at(5).get("name")

We are currently thinking about how we can implement the property
expressions. We are discussing this in SANDBOX-464 [1] and there is already
a patch. I'm currently unsure whether we should allow mixing up the fluent
API and property expressions. The contributor makes some good examples of
what kind of awful code could be created:

on(addressBook).get("provider(google).contact[5]
").getMapped("address").with("home").get("street.yetAnotherNestedProperty")

on the other hand I don't want to force people into doing stuff like this:

String path = ...int pos = ...
on(bean).get(path + "[" + pos + "]");


Currently I'm tempted to allow mixing up both API styles, but I'd like to
here your opinion first.

Benedikt

[1] https://issues.apache.org/jira/browse/SANDBOX-464

-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Reply via email to