peichhorn/lombok-pg — Issue #63: Annotation to add more object meta-data
Author: nickspacek
Created: 2011-12-09 00:23:02+00:00
State: open

I'm not sure where to discuss ideas (didn't see a discussion group), but I was looking to write some code for passing queries to our service layer and thought how nice it would be to have a way to reference fields strongly, and got me thinking about how you have to rely on passing Strings through the Reflection APIs to get at class details.

It seems like Lombok might be able to generate something within the class that would let you refer to methods and fields in a stronger manner (might not be the best description). Maybe this isn't as useful as I'm imagining, but something like this might be possible:

import static fake.QuerySupport.*;
import fake.pojo.Customer;

// Customer.FIELDS or .PROPERTIES, or something shorter like .F
// Not really conventional to use camel-casing on something like this, but looks nicer

Query q = when(Customer.F.firstName).beginsWith("A").or().when(Customer.F.age).greaterThan(5);
service.findCustomers(q);

That's probably a terrible DSL, I'm sure others have written better, but all I'm trying to get at is that this lombok-pg feature would generate ways to reference the fields/methods. Maybe it wouldn't be as simple as an enum, it could have a class hierarchy of its own (maybe even something that already exists in the Reflection API).

Perhaps something along these lines is already achievable!