Class ConstructorTemplate.nullCheck
java.lang.Object
de.japkit.test.members.constructor.ConstructorTemplate.nullCheck
- Enclosing class:
- ConstructorTemplate
@CodeFragment(condFun=hasNotNull.class, imports=java.util.Objects.class, code="Objects.requireNonNull(#{surrounded}, \"#{name} must not be null.\")") class ConstructorTemplate.nullCheck extends java.lang.Object
A code fragment that adds a null check to the field assignment if the
field has a
NotNull
annotation. It expects the field (from the
annotated class) as current src.
Since nullCheck is used as a fragment that surrounds other code, there is some special EL variable "surrounded" available here that contains the code to be surrounded.
If the field has no NotNull
annotation, the fragments does
nothing. For a surrounding fragment this means, the code to be surrounded
is left as it is.
-
Constructor Summary
Constructors Constructor Description nullCheck()
-
Method Summary
-
Constructor Details
-
nullCheck
nullCheck()
-