title: Scala pattern match against a Java enum type
body: <p>I have a Java enum type that has some Strings and I want to pattern match against in. Here is what I have done so far:</p>
  
  <pre><code>public enum MyEnum {
    YEAR, MONTH;
  }
  </code></pre>
  
  <p>In my scala function, I do the following:</p>
  
  <pre><code>timePeriod.toUpperCase match {
    case MyEnum.YEAR.name =&gt; doSomething
    case MyEnum.MONTH.name =&gt; doSomething
  }
  </code></pre>
  
  <p>When I compile, I get the following error:</p>
  
  <pre><code>stable identifier required, but YEAR.name found
  </code></pre>
  
  <p>It is not informative enough for me to understand the root cause of the error. Any ideas?</p>