title: Using @IntDef in a LiveData Observable
body: <p>I'm looking at how to update some existing code to use the new Android LiveData architectural pattern.  Hopefully the code sample is self explanatory, I'm struggling to get @IntDef / @Interface to work with Live Data.  I'm happy to create methods on the ViewModel for SetAnsweredCorrectly, SetCheated, etc or to create a MutableLiveData property and set it in code, it's just I'm struggling to see how to use anything other than a normal Integer, which loses the type safety.</p>
  
  <pre><code>public class QuestionViewModel extends ViewModel {
  
      public static final int UNANSWERED = 0;
      public static final int ANSWERED_CORRECTLY = 1;
      public static final int ANSWERED_INCORRECTLY = 2;
      public static final int CHEATED = 3;
  
      @IntDef({UNANSWERED, ANSWERED_CORRECTLY, ANSWERED_INCORRECTLY, CHEATED})
      @Retention(RetentionPolicy.SOURCE)
      public @interface AnswerState{}
  
      private @AnswerState int answeredState;
  
      public Question()
      {
          this.setAnsweredState(UNANSWERED);
      }
  
      public @AnswerState int getAnsweredState() {
          return answeredState;
      }
  
      public void setAnsweredState(@AnswerState int answeredState) {
          this.answeredState = answeredState;
      }
  </code></pre>