001    package org.kuali.student.enrollment.courseoffering.dto;
002    
003    /**
004     * @Author Sri komandur@uw.edu
005     *
006     * Our use case involves jpa persistence, storing enum in attributes
007     * as 'string' and conversion back to enum This design, explicitly
008     * specifying 'business type' gives flexibility and avoids pitfalls in
009     * the future when a stored enum is renamed, for example.
010     */
011    public enum FinalExam {
012    
013        STANDARD("STANDARD"), ALTERNATE("ALTERNATE"), NONE("NONE");
014        
015        private final String name;
016    
017        FinalExam(String name) {
018            this.name = name;
019        }
020    
021        public static FinalExam toEnum(String value) {
022            if (value != null) {
023                for (FinalExam finalExam : values()) {
024                    if (finalExam.name.equals(value)) {
025                        return finalExam;
026                    }
027                }
028            }
029            return FinalExam.NONE;
030        }
031    
032        @Override
033        public String toString() {
034            return name;
035        }
036    }