Print

Print


Author: [log in to unmask]
Date: Wed Aug 26 23:31:58 2015
New Revision: 3414

Log:
Add a method that returns a TrackType enum of the given name.

Modified:
    java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackType.java

Modified: java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackType.java
 =============================================================================
--- java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackType.java	(original)
+++ java/trunk/tracking/src/main/java/org/hps/recon/tracking/TrackType.java	Wed Aug 26 23:31:58 2015
@@ -12,10 +12,14 @@
     //       enum constants should be simply added to the end of the list.
     
     /** Enum values corresponding to different tracking strategies */
-    S123_C4_E56(1000), // Seed 123, confirm 4, extend 56 
-    S123_C5_E46(1001), // Seed 123, confirm 5, extend 46
-    S345_C2_E16(1003), // Seed 345, confirm 2, extend 16
-    S456_C3_E21(1004); // Seed 456, confirm 3, extend 21
+    /** Seed 123, confirm 4, extend 56 */
+    S123_C4_E56(1000),
+    /** Seed 123, confirm 5, extend 46 */
+    S123_C5_E46(1001),
+    /** Seed 345, confirm 2, extend 16 */
+    S345_C2_E16(1003),
+    /** Seed 456, confirm 3, extend 21 */
+    S456_C3_E21(1004); 
     
     private int type; 
    
@@ -32,12 +36,27 @@
     public int getType() { 
         return type; 
     }
+    
+    /**
+     * Returns the {@link TrackType} with the specified name.  If a 
+     * {@link TrackType} with that name doesn't exist, it returns null.
+     * 
+     * @param name The name of the TrackType enum constant to return
+     * @return The TrackType enum constant of the given name or null if it 
+     *         doesn't exist. 
+     */
+    public static TrackType getType(String name) {
+        for (TrackType trackType : values()) {
+            if (trackType.name().equals(name)) return trackType;
+        }
+        return null;
+    }
  
     /**
      * Returns true if the specified {@link TrackType} is equal to this enum
      * constant.
      * 
-     * @param trackType : enum constant to check
+     * @param trackType enum constant to check
      * @return true if the specified {@link TrackType} is equal to this enum
      *         constant
      */