The title pretty much sums it up. I'm wondering if I need to include static variables (which I probably don't) in the constructor.
Given that static variables are static I suspect that they are probably not. But I didnt find any answers to this question on stackoverflow.
No static fields are skipped while using these lombok annotations
@NoArgsConstructor
@RequiredArgsConstructor
@AllArgsConstructor
Static fields are skipped by these annotations.
If you want to declare constructor with static fields then you can declare the one explicitly, but you might end up with compiler error if any of those constructors have same signature
Unlike most other lombok annotations, the existence of an explicit constructor does not stop these annotations from generating their own constructor. This means you can write your own specialized constructor, and let lombok generate the boilerplate ones as well. If a conflict arises (one of your constructors ends up with the same signature as one that lombok generates), a compiler error will occur.
The answer is no as you can check in javadoc:
An all-args constructor requires one argument for every field in the class.
or official documentation: https://projectlombok.org/features/Constructor
RequiredArgsConstructor
includes in the constructor all final
fields. However, you cannot have a static final
variable not initialized (as they can be used even with no instance of that class)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With