View Javadoc
1   package org.kuali.student.enrollment.courseoffering.dto;
2   
3   /**
4    * @Author Sri komandur@uw.edu
5    *
6    * Our use case involves jpa persistence, storing enum in attributes
7    * as 'string' and conversion back to enum This design, explicitly
8    * specifying 'business type' gives flexibility and avoids pitfalls in
9    * the future when a stored enum is renamed, for example.
10   */
11  public enum FinalExam {
12  
13      STANDARD("STANDARD"), ALTERNATE("ALTERNATE"), NONE("NONE");
14      
15      private final String name;
16  
17      FinalExam(String name) {
18          this.name = name;
19      }
20  
21      public static FinalExam toEnum(String value) {
22          if (value != null) {
23              for (FinalExam finalExam : values()) {
24                  if (finalExam.name.equals(value)) {
25                      return finalExam;
26                  }
27              }
28          }
29          return FinalExam.NONE;
30      }
31  
32      @Override
33      public String toString() {
34          return name;
35      }
36  }