Coverage Report - com.aragost.javahg.Phase
 
Classes in this File Line Coverage Branch Coverage Complexity
Phase
72%
8/11
50%
3/6
4
 
 1  
 package com.aragost.javahg;
 2  
 
 3  
 /**
 4  
  * Enum type to represent phases introduced in Mercurial 2.1
 5  
  */
 6  13
 public enum Phase {
 7  
 
 8  1
     PUBLIC, DRAFT, SECRET;
 9  
 
 10  
     /**
 11  
      * Return the Phase that correspond to the specified text.
 12  
      * <p>
 13  
      * The text is what mercurial uses in the command output (i.e.
 14  
      * public, draft, or secret).
 15  
      * 
 16  
      * @param s
 17  
      * @return the Phase that correspond to the specified text. null is returned for the empty string.
 18  
      * @throws IllegalArgumentException
 19  
      *             if no phase correspond to the specified text
 20  
      */
 21  
     public static Phase fromText(String s) {
 22  22
         for (Phase p : Phase.values()) {
 23  22
             if (p.text.equals(s)) {
 24  12
                 return p;
 25  
             }
 26  
         }
 27  0
         if (s.equals("")) {
 28  0
             return null;
 29  
         }
 30  0
         throw new IllegalArgumentException("No phase for " + s);
 31  
     }
 32  
 
 33  
     private String text;
 34  
 
 35  3
     private Phase() {
 36  3
         this.text = name().toLowerCase();
 37  3
     }
 38  
 }