title: How to ensure completeness in an enum switch at compile time?
body: <p>I have several switch statements which test an <code>enum</code>. All <code>enum</code> values must be handled in the <code>switch</code> statements by a <code>case</code> statement. During code refactoring it can happen that the <code>enum</code> shrinks and grows. When the <code>enum</code> shrinks the compiler throws an error. But no error is thrown, if the the <code>enum</code> grows. The matching state gets forgotten and produces a run time error. I would like to move this error from run time to compile time. Theoretically it should be possible to detect the missing <code>enum</code> cases at compile time. Is there any way to achieve this?</p>
  
  <p>The question exists already "<a href="https://stackoverflow.com/questions/3999942/how-to-detect-a-new-value-was-added-to-an-enum-and-is-not-handled-in-a-switch?rq=1">How to detect a new value was added to an enum and is not handled in a switch</a>" but it does not contain an answer only an Eclipse related work around.</p>