mavlink / MAVSDK-Java

MAVSDK client for Java.
68 stars 40 forks source link

Template improvements involving addition of @CheckReturnValue and @NonNull #75

Closed divyanshupundir closed 2 years ago

divyanshupundir commented 2 years ago
  1. @CheckReturnValue annotation marks methods whose return values should be checked. This is required because it informs the IDEs to throw a warning in case the return value is not used. For example, the users may use the methods and forget to subscribe to the RxJava objects:
system.getAction().setTakeoffAltitude(20);

Which should instead be:

Disposable d = system.getAction()
  .setTakeoffAltitude(20)
  .subscribe(onComplete, onError);

In the first commit, @CheckReturnValue has been added to the public methods that return a Completable, a Flowable or a Single.

  1. When null is passed for the @NonNull annotated parameter, the IDE throws a warning in the case of Java and it's a compile-time error when called from Kotlin.

In the second commit, parameters of public methods have been annotated with NonNull. Though I had gone through the code on the gRPC side and found that the methods were null-intolerant, please let me know in case MAVSDK-Java actually expects null at someplace.