0

Functional is declared as:

Object functionName(@Nullable long inputPar)

@Nullable annotation accepts null as input parameter on the function call.

Could I, inside the function, write a condition asking if the inputPar is null?

if(inputPar == null) is invalid, since it's a primitive type. What would be the most efficient alternative approach?

1 Answers1

0

The most efficient approach is to realize that even though you have marked inputPar as @Nullable, it is literally impossible for it to be null. Marking a parameter @Nullable does not actually make a primitive value able to be null.

The only way to make this "actually" nullable is to write @Nullable Long inputPar, and use the wrapper type instead of the primitive.

Louis Wasserman
  • 191,574
  • 25
  • 345
  • 413