kokorin / lombok-presence-checker

Lombok extension which generates Presence Check methods
Apache License 2.0
11 stars 2 forks source link

Suggested change to hasXxx implementation #5

Open cptully opened 2 years ago

cptully commented 2 years ago

I forked your project, intending to make this change myself for something at work but I cannot seem to pull all of the dependencies when behind my corporate firewall... I will have to try on my personal computer this weekend.

We use HAPI FHIR and they have a more robust implementation of hasXxxx() that you may find interesting:

public boolean hasXxxx() { return this.xxxx != null && !this.xxxx.isEmpty(); }

kokorin commented 2 years ago

Sorry for very late reply.

Main goal for this project was to generate MapStruct presence checkers for partial update REST requests. With such requests null values must not be treated as absent values. Absent values doesn't cause update, but null values in DTO causes Entity field to be set to null.

Another issue is that not every type has isEmpty() method.

Actually this project is mainly for academical purpose, I had an interest in hacking Lombok. So feel free to use it as ground for your own Lombok plugin.