Up to now, my only solution is to combine the @EnsuresNonNullIf
-annotation with SuppersWarnings("nullness")
. E.g.:
@SuppressWarnings("nullness")
@EnsuresNonNullIf(expression = {"get(#1)", "getMatchingStoredKey(#1)", "getStrict(#1)", "lookup(#1)"}, result = true)
public boolean containsKeyStrict(final @Nullable Class<? extends TKeyClass> key) {
return super.containsKey(key);
}
To scope the @SuppressWarnings
you can delegate the implementation to a method not annotated @EnsuresNonNullIf.