openpojo
openpojo copied to clipboard
How can I declare derived/calculated fields - ones which only have getters and not setters ?
I have some pojos which set/get 4 datetime fields - and we also have related
fields *and* getters (not setters) which covert those date times into local
time zone date times. Can this be supported ?
e.g.
private Date startSate; // with getter and setter - setter also coverts and
sets startLocalDate
private LocalDateTime startLocalDate; // with just setter
Original issue reported on code.google.com by [email protected] on 7 Oct 2014 at 4:18
I realise if I dont have a field for the derived value - and calculate it in
the getter everytime, then this will work... but it would be more efficient if
I could store the derived values in fields to use in multiple calls to a
getter. It depends on how often I anticipate the getters to be called.
Original comment by [email protected] on 7 Oct 2014 at 4:25
It appears you want to write your own rule that implements the "setter must
exist unless derived field"...
you can do it through an annotation that flags those fields as derived and then
skip them in your rule.
Hope this helps...
Original comment by [email protected] on 8 Oct 2014 at 4:30
- Added labels: Type-Enhancement
- Removed labels: Type-Defect
#90 SetterTester and GetterTester improvement