View Javadoc

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