In the interface that describes the service, I have methods similar to this:
TaskCard saveTaskCard(@NonNull TaskCard card, User user);
I put the @NonNull (lombok) annotation before an argument, but it won't work on its own if the same annotation isn't in the implementation. This means that in the methods of the class implementing this interface, I will need to put this annotation again, thereby duplicating the code.
@Override
@Transactional
public TaskCard saveTaskCard(@NonNull TaskCard taskCard, User user) {
taskCard.setUser(user);
return repository.save(taskCard);
}
The question is, is this how it should be? If you put this annotation only in the interface, they will not work, and if you put it only in the class that implements the interface, then API users may not understand that null cannot be passed to these methods. What should I do?