title: Enum values().length vs private field
body: <p>I have enumeration like this:</p>
  
  <pre><code>public enum Configuration {
      XML(1),
      XSLT(10),
      TXT(100),
      HTML(2),
      DB(20);
  
      private final int id;
      private Configuration(int id) {
          this.id = id;
      }
      public int getId() { return id; }
  }
  </code></pre>
  
  <p>Sometimes I need to check how many fields I have in enumeration. What is the best solution?
  Should I use a method "values().length"? Or maybe, I must create constant field in enumeration like this:</p>
  
  <pre><code>public enum Configuration {
      XML(1),
      XSLT(10),
      TXT(100),
      HTML(2),
      DB(20);
  
      private final int id;
      private Configuration(int id) {
          this.id = id;
      }
      public int getId() { return id; }
  
      public static final int Size = 5;
  }
  </code></pre>
  
  <p>What is the fastest and more elegant solution?</p>