title: Android - Is it ok to put @IntDef values inside @interface?
body: <p>I'm trying to implement <code>@IntDef</code> annotation in Android development.</p>
  
  <p><strong>First Method</strong>: it looks great with the definition separated in a <code>Constant.java</code> class:</p>
  
  <pre><code>public class Constant {
     @IntDef(value={SORT_PRICE, SORT_TIME, SORT_DURATION})
     @Retention(RetentionPolicy.SOURCE)
     public @interface SortType{}
     public static final int SORT_PRICE = 0;
     public static final int SORT_TIME = 1;
     public static final int SORT_DURATION = 2;
  }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>@Constant.SortType int sortType = Constant.SORT_PRICE;
  </code></pre>
  
  <p>But things get a lot messier when there's multiple definition (e.g UserType, StoreType, etc) in one file. </p>
  
  <p><strong>Second Method:</strong> So I came up with something like this to separate values between definition:</p>
  
  <pre><code>public class Constant {
     @IntDef(value={SortType.SORT_PRICE, SortType.SORT_TIME, SortType.SORT_DURATION})
     @Retention(RetentionPolicy.SOURCE)
     public @interface SortTypeDef{}
  
     public static class SortType{
         public static final int PRICE = 0;
         public static final int TIME = 1;
         public static final int DURATION = 2;
     }
  }
  </code></pre>
  
  <p>Usage:</p>
  
  <pre><code>@Constant.SortTypeDef int sortType = Constant.SortType.PRICE;
  </code></pre>
  
  <p>But as you can see, I created two different name for it: <code>SortTypeDef</code> and <code>SortType</code></p>
  
  <p><strong>Third Method:</strong> I tried to move the list of possible values inside <code>@interface</code>:</p>
  
  <pre><code>public class Constant {
     @IntDef(value={SortType.SORT_PRICE, SortType.SORT_TIME, SortType.SORT_DURATION})
     @Retention(RetentionPolicy.SOURCE)
     public @interface SortType{
         int PRICE = 0;
         int TIME = 1;
         int DURATION = 2;
     }
  }
  </code></pre>
  
  <p>Usage </p>
  
  <pre><code>@Constant.SortType int sortType = Constant.SortType.PRICE;
  </code></pre>
  
  <p>While it does work, I don't know what is the drawback.
  Is it okay to put the possible values of <code>@IntDef</code> inside <code>@interface</code>? Is there any performance differences across the three methods above?</p>