|
Re: Announcing Pojomatic 1.0
|
Posted: Apr 27, 2010 2:05 PM
|
|
> On a side note, the stuff you've done here with Pojomatic > could be trivially adapted to an Equalator methodology, > right?
Sort of. Since Pojomatic is configured by annotations, it would only be possible to configure a single Equalator. This is generally a problem with annotations - since they are making statements about the class itself, they are ill suited to talking about a view of a class. (Ever try to put JPA annotations on a single bean to support two different persistence models?).
That said, annotations do provide a certain level of type safety that's hard to get otherwise. Since Pojomatic was designed for the use case of equals, hashCode and toString, and these methods are fundamentally part of the class (for better or worse), annotations are a good fit.
If Java had a type safe way to reference class fields the way it has for referencing classes (i.e. Class<?> c = String.class), then it would be possible to configure alternate Pojomators without sacrificing type safety. Lacking that, the only option I can see for supporting multiple Pojomators for a given class would be one that involved string-based configuration - something like new Pojomator(Bean.class, "name", "age").
|
|