commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yogesh Rao <yog...@gmail.com>
Subject Re: [SANDBOX][BEANUTILS2] Property expressions
Date Tue, 20 May 2014 08:47:00 GMT
How about giving the user the options

1. go the traditional way of calling the series of get methods and perform
the operation
or
2. the pure expression way (this wouldnt allow the user to mix with the
first style)

the 2nd option does seem very similar to what jxpath does for living, but
having said this i am not very sure of all the feature it comes bundled
with. Does it handle custom converters aswell?

Regards,
-Yogesh



On Fri, May 2, 2014 at 11:24 PM, Gary Gregory <garydgregory@gmail.com>wrote:

> Nah, I'm just talking around the water cooler,  thinking aloud...
>
> Gary
>
> <div>-------- Original message --------</div><div>From: Benedikt Ritter
<
> britter@apache.org> </div><div>Date:05/02/2014  12:59  (GMT-05:00)
> </div><div>To: Commons Developers List <dev@commons.apache.org>
> </div><div>Subject: Re: [SANDBOX][BEANUTILS2] Property expressions
> </div><div>
> </div>So you're saying we should leave this out of BU2?
>
>
> 2014-05-02 12:55 GMT+02:00 Gary Gregory <garydgregory@gmail.com>:
>
> > There is also our own jxpath.
> >
> > Gary
> >
> > <div>-------- Original message --------</div><div>From: Benedikt
Ritter <
> > britter@apache.org> </div><div>Date:05/02/2014  06:40  (GMT-05:00)
> > </div><div>To: Commons Developers List <dev@commons.apache.org>
> > </div><div>Subject: [SANDBOX][BEANUTILS2] Property expressions
> </div><div>
> > </div>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
> >
>
>
>
> --
> http://people.apache.org/~britter/
> http://www.systemoutprintln.de/
> http://twitter.com/BenediktRitter
> http://github.com/britter
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message