Groovy/Grails has a very neat feature* called dynamic finders as a part of GORM, implemented using "phantom methods", where it uses a dynamic message interceptor to field messages to an object, and if the name is not a current actual methods, but matches a specific format of: (field + comparator) it will synthesize a filter predicate method of that logic. Groovy has a special support for this in a “MethodMissing” method, and Grails/GORM adds this synthesized finder logic using that hook.
For example, one can do something like this:
students.gpaLessThan(3.0).nameLike("Smith").stateEquals("Iowa");
and get a filtered result from a collection, and none of these methods are user written.
It seems that one could do something similar (parallel) in Java, using a dynamic proxy for the message interceptor and synthesis. I was going to play with this, but wonder if anyone else has already done something like this. Further I wonder if using annotations one could implement some static type checking on such synthesized names, since the annotation could at least generate code with method references, which the compiler would then check.
[*I am not a Groovy user, but just read some samples of this feature, so I may have not been correct on the Groovy implementation details.]
Take a look at Spring Roo. It's a java-based framework that takes a lot of inspiration from Grails. Roo has an interesting implementation of dynamic finders that uses aspects.