title: How to let Android Studio know that there is a wrong argument value?
body: <p>I find Android Studio a very good IDE. It seems like that it will tell you when you enter a wrong argument for a method. For instance:</p>
  
  <pre><code>view.setVisibility(1);
  </code></pre>
  
  <p>Android Studio says that I can only use <code>View.GONE</code>, <code>View.INVISIBLE</code> and <code>View.VISIBLE</code> for that argument. When I go into the definition of the <code>setVisibility</code> method, I see that there is an annotation on the parameter, called "<code>@Visibility</code>". So I guess Android Studio uses annotations to check whether the argument is valid. But how do I create my own annotations that can be checked by Android Studio?</p>
  
  <p>For example, I have this method:</p>
  
  <pre><code>public void moveHorizontally (int direction) {
      //code
  }
  </code></pre>
  
  <p>I want the direction argument to be either <code>LEFT</code> or <code>RIGHT</code> which are constants defined in this class.</p>
  
  <p>How can I create such an annotation so that Android Studio can detect invalid arguments?</p>