Affects Version/s: 0.2-incubating
Fix Version/s: 0.2-incubating
Currently, the code reuse issue exposed in
BVAL-47 has been solved using a common abstract validator which is subclassed by the jsr303 and core validators.
I have been thinking about how to solve the type safety problems I exposed in my mail. I propose a different solution (no inheritance, and a strategy pattern is used to return the validation flow to the correct method in each validator in a type safe way). The reasons why I propose removing the current inheritance scheme are:
- Inheritance is just used for code reuse. The 2 validatos have different interfaces to which they respond to, and there is no code in which a reference to an "abstract" validator is or should be held.
- I haven't found a way of removing class casting issues with the inheritance strategy. I know that at the moment it is somewhat "easy" to see that most of the casts can't fail, but I find it cleaner and safer to code it in a way in which type safety is enforced by the compiler.
Please take into account that the proposed diff is a preliminar work that simply shows a way in which this could be done. If you prefer this to the current solution with inheritance, further work would be done to better ensure type safety, access to the property treatsMapsLikeBeans would be centralized, etc.