Timeline for What is the best way to know if all the variables in a Class are null?
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Feb 22, 2023 at 11:51 | comment | added | Calvin P. | I find myself needing to do something similar to the OP’s question and my thoughts turned first to the equals method. I originally thought to have an isEmpty method that compared to a new instance of the class, but I like the idea of using a static final object more. Nice solution! | |
Dec 24, 2020 at 15:07 | history | edited | Martin Tarjányi | CC BY-SA 4.0 |
Refactor answer
|
Jan 15, 2020 at 6:10 | comment | added | Martin Tarjányi | that's why I used the lombok annotation | |
Jan 15, 2020 at 6:09 | comment | added | Tamim Attafi | @MartinTarjányi but equals() method in java compares instances and not their field values.. you'll need to override equals() and hashCode(). | |
Jul 25, 2019 at 17:13 | comment | added | Martin Tarjányi | Empty is a static field here, so it shouldn't be a problem. | |
Mar 5, 2019 at 0:34 | comment | added | Sp4Rx |
This will create an extra object EMPTY along with each object. Will this affect the performance?
|
|
Feb 12, 2017 at 14:19 | review | Late answers | |||
Feb 12, 2017 at 14:20 | |||||
Feb 12, 2017 at 14:14 | review | First posts | |||
Feb 12, 2017 at 14:44 | |||||
Feb 12, 2017 at 14:13 | history | edited | Martin Tarjányi | CC BY-SA 3.0 |
added 127 characters in body
|
Feb 12, 2017 at 14:04 | history | answered | Martin Tarjányi | CC BY-SA 3.0 |