diff --git a/app/src/main/java/com/nicobrailo/pianoli/Piano.java b/app/src/main/java/com/nicobrailo/pianoli/Piano.java
index a64f1bc..8c184f0 100644
--- a/app/src/main/java/com/nicobrailo/pianoli/Piano.java
+++ b/app/src/main/java/com/nicobrailo/pianoli/Piano.java
@@ -1,10 +1,12 @@
package com.nicobrailo.pianoli;
import android.util.Log;
+import androidx.annotation.NonNull;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.Objects;
/**
* Backing model / state of our virtual piano keyboard.
@@ -140,9 +142,10 @@ private boolean isOutOfRange(int key_idx) {
* @return Per the {@link java.util.Collection#add(Object)} contract, true
if the listener list changed as a result of this add,
* false
if it was already subscribed.
*/
- public boolean addListener(PianoListener l) {
- if (l != null // avoid NullPointerExceptions on notify
- && !listeners.contains(l)) { // don't double-add listeners, to avoid double-triggers
+ public boolean addListener(@NonNull PianoListener l) {
+ Objects.requireNonNull(l, "Listeners must not be null to avoid NullPointerExceptions on notify");
+
+ if (!listeners.contains(l)) { // don't double-add listeners, to avoid double-triggers
listeners.add(l);
return true;
}