title: 'Subset' of Enum values in Java
body: <p>I have a Java class that is something of the form:-</p>
  
  <pre><code>public class Angle
  {
      ANGLE_TYPE angleType;
  
      ANGLE_TYPE defaultAngleType = ANGLE_TYPE.RAD;
  
      enum ANGLE_TYPE
      {
          DEG, RAD, DEGMIN, DEGMINSEC;
      }
  }
  </code></pre>
  
  <p>The class has an 'enum' defined, as can be seen. My question regards the instance variable, 'defaultAngleType'. I want it to be the case so that this variable can only be assigned the values RAD or DEG, and to throw an error otherwise.</p>
  
  <p>Any idea how to acheive this?</p>