This access strategy would be quite different from others but it would enable use cases like: - enforcing class invariants through the constructor, - immutable fields or classes (all fields) and - support for Java 10 value types which are planned to be immutable.
Parameter names (introduced in Java 8) could be used to fulfill this goal. Constructor would be used for writing entity state and for reading entity state accessors could be used.
To simplify the initial implementation following requirements might be added: - constructor access strategy can not be applied to classes that are to be proxied (for example in lazy loading scenarios) - only one constructor should be specified (for more complex use cases static factory methods can be suggested) |
|