public @interface Pure
Indicates that if the method is a pure method, so calling it multiple times with the same arguments yields the same results.
The method should not have any visible side-effect. Non-visible benevolent side effects (e.g., caching) are possible.
For example, consider the following declaration and uses:
@Nullable Object getField(Object arg) { ... } ... if (x.getField(y) != null) { x.getField(y).toString(); }
Ordinarily, the Nullness Checker would issue a warning regarding the toString() call, because the receiver x.getField(y) might be null, according to the @Nullable annotation in the declaration of getField. If you change the declaration of getField to
@Pure @Nullable Object getField(Object arg) { ... }
then the Nullness Checker issues no warnings, because it can reason that the two invocations x.getField(y) have the same value, and therefore that x.getField(y) is non-null within the then branch of the if statement.