001    package edu.nrao.sss.model.proposal;
002    
003    import edu.nrao.sss.util.EnumerationUtility;
004    
005    /**
006     * An enumeration of scientific exploration types.
007     * 
008     * @author David M. Harland
009     * @since   2006-03-03
010     */
011    public enum ScientificType
012    {
013      /** Represents an extragalactic scientific exploration.
014       *  <p>
015       *  The name of this element (for use with
016       *  {@code getInstanceFromName(String)}) is
017       *  <i>EXTRAGALACTIC</i>.</p>
018       */
019      EXTRAGALACTIC,
020    
021      /** Represents a scientific exploration of something in the solar system.
022       *  <p>
023       *  The acceptable names of this element (for use with
024       *  {@code getInstanceFromName(String)}) are
025       *  <i>SOLAR_SYSTEM</i> and <i>Solar System</i>.</p>
026       */
027      SOLAR_SYSTEM,
028      
029      /** Represents a scientific exploration of something in our galaxy.
030       *  <p>
031       *  The name of this element (for use with
032       *  {@code getInstanceFromName(String)}) is
033       *  <i>GALACTIC</i>.</p>
034       */
035      GALACTIC,
036      
037      /** Represents a scientific exploration of a stellar object.
038       *  <p>
039       *  The name of this element (for use with
040       *  {@code getInstanceFromName(String)}) is
041       *  <i>STELLAR</i>.</p>
042       */
043      STELLAR,
044      
045      /** Represents a scientific exploration of a type other than those
046       *  listed herein.
047       *  <p>
048       *  The name of this element (for use with
049       *  {@code getInstanceFromName(String)}) is
050       *  <i>OTHER</i>.</p>
051       */
052      OTHER,
053      
054      /** Represents a scientific exploration of unknown type.
055       *  <p>
056       *  This element is used to implement the
057       *  <i>Null Object Pattern</i>.  In situations where a method might
058       *  be tempted to return <i>null</i>, this element is returned instead.</p>
059       */
060      UNKNOWN;
061    
062      private ScientificType()
063      {
064      }
065    
066      /**
067       * Returns a default scientific type.
068       * @return a default scientific type.
069       */
070      public static ScientificType getDefault()
071      {
072        return UNKNOWN;
073      }
074      
075      /**
076       * Returns a text representation of this enumeration constant.
077       * @return a text representation of this enumeration constant.
078       */
079      public String toString()
080      {
081        return EnumerationUtility.getSharedInstance().enumToString(this);
082      }
083    
084      /**
085       * Returns the scientific type represented by {@code text}.
086       * <p>
087       * For details about the transformation, see
088       * {@link EnumerationUtility#enumFromString(Class, String)}.</p>
089       * 
090       * @param text a text representation of a scientific type.
091       * 
092       * @return the scientific type represented by {@code text}.
093       */
094      public static ScientificType fromString(String text)
095      {
096        return EnumerationUtility.getSharedInstance()
097                                 .enumFromString(ScientificType.class, text);
098      }
099    }