title: @IntDef annotation and return value from other's code that cannot be annotated or how to temporarily disable annotation from affecting the code?
body: <p>I am using <a href="https://developer.android.com/reference/android/support/annotation/IntDef.html" rel="noreferrer">IntDef</a> from <a href="https://sites.google.com/a/android.com/tools/tech-docs/support-annotations" rel="noreferrer">Android Support annotation</a> in my code (but my question is wider in scope so please keep reading :) like this:</p>
  
  <pre><code>public class UiLockMode
  {
      @IntDef({DEFAULT, NONE, VISIBLE, TRANSPARENT})
      @Retention(RetentionPolicy.SOURCE)
      public @interface AllowedValues {}
  
      public static final int DEFAULT     = 0;
      public static final int NONE        = 1;
      public static final int VISIBLE     = 2;
      public static final int TRANSPARENT = 3;
  }
  </code></pre>
  
  <p>Next, I got some other methods annotated with it like this:</p>
  
  <pre><code>protected void setLockMode(@UiLockMode.AllowedValues int lockMode) {
      ...
  </code></pre>
  
  <p>At that point is all fine and nice but the problem shows up whenever I'd like to pass return value from other methods to <code>setLockMode()</code>, like i.e. from Parcelable implementation:</p>
  
  <pre><code>private Foo(Parcel in) {
      ...
      setLockMode(in.getInt());
  </code></pre>
  
  <p>In such case my IDE complains that I am only allowed to use <code>DEFAULT, NONE, VISIBLE, TRANSPARENT</code> with <code>setLockMode()</code>. But <code>getInt()</code> is not my method so I cannot annotate its return value and make all this happy. I am also almost sure this is not unique use case but I failed to find the way to either temporarily disable <code>AllowedValues</code> annotation from complaining here or to "cast" return value from <code>getInt()</code> to make <code>AllowedValue</code> not complaining. </p>
  
  <p>So my questions are: is there any way of solving this problem? Maybe I am missing something obvious about annotations but maybe I shall be creating bug report to make Google address this problem instead? </p>
  
  <p>Any input or thought appreciated.</p>