001 package edu.nrao.sss.model.proposal; 002 003 import edu.nrao.sss.util.EnumerationUtility; 004 005 //TODO Write test class 006 /** <i>Placeholder for time when we integrate proposal work.</i> 007 * An enumeration of professional status types. 008 * 009 * @version 1.1 010 * @since 2006-03-09 011 */ 012 public enum ProfessionalStatus 013 { 014 /** 015 * The undergraduate student status. 016 * <p> 017 * The acceptable names of this element (for use with 018 * {@code getInstanceFromName(String)}) are 019 * <i>UNDERGRADUATE</i> and <i>Undergraduate Student</i>.</p> 020 */ 021 UNDERGRADUATE("Undergraduate Student"), 022 023 /** 024 * The graduate student status. 025 * <p> 026 * The acceptable names of this element (for use with 027 * {@code getInstanceFromName(String)}) are 028 * <i>GRADUATE</i> and <i>Graduate Student</i>.</p> 029 */ 030 GRADUATE("Graduate Student"), 031 032 /** 033 * Any status not covered by the other types. 034 * <p> 035 * The acceptable names of this element (for use with 036 * {@code getInstanceFromName(String)}) are 037 * <i>ALL_OTHERS</i> and <i>All Others</i>.</p> 038 * <p> 039 * This element is used to implement the 040 * <i>Null Object Pattern</i>. In situations where a method might 041 * be tempted to return <i>null</i>, this element is returned instead.</p> 042 */ 043 ALL_OTHERS("All Others"); 044 045 private final String name; 046 047 private ProfessionalStatus(String name) 048 { 049 this.name = name; 050 } 051 052 /** 053 * Returns a default professional status. 054 * @return a default professional status. 055 */ 056 public static ProfessionalStatus getDefault() 057 { 058 return ALL_OTHERS; 059 } 060 061 public String toString() 062 { 063 return name; 064 } 065 066 /** 067 * Returns the professional status represented by {@code text}. 068 * <p> 069 * For details about the transformation, see 070 * {@link EnumerationUtility#enumFromString(Class, String)}.</p> 071 * 072 * @param text a text representation of a professional status. 073 * 074 * @return the professional status represented by {@code text}. 075 */ 076 public static ProfessionalStatus fromString(String text) 077 { 078 return EnumerationUtility.getSharedInstance() 079 .enumFromString(ProfessionalStatus.class, 080 text); 081 } 082 }