Coverage Report - javax.faces.event.PhaseId
 
Classes in this File Line Coverage Branch Coverage Complexity
PhaseId
69%
23/33
0%
0/6
2
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package javax.faces.event;
 20  
 
 21  
 import java.util.ArrayList;
 22  
 import java.util.Collections;
 23  
 import java.util.List;
 24  
 import javax.faces.FacesException;
 25  
 
 26  
 /**
 27  
  * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
 28  
  */
 29  
 public class PhaseId implements Comparable
 30  
 {
 31  
     // FIELDS
 32  
     public static final PhaseId ANY_PHASE;
 33  
     public static final PhaseId APPLY_REQUEST_VALUES;
 34  
     public static final PhaseId INVOKE_APPLICATION;
 35  
     public static final PhaseId PROCESS_VALIDATIONS;
 36  
     public static final PhaseId RENDER_RESPONSE;
 37  
     public static final PhaseId RESTORE_VIEW;
 38  
     public static final PhaseId UPDATE_MODEL_VALUES;
 39  
     public static final List<PhaseId> VALUES;
 40  
 
 41  
     static
 42  
     {
 43  2
         int i = 0;
 44  2
         ArrayList<PhaseId> list = new ArrayList<PhaseId>(6);
 45  
 
 46  2
         ANY_PHASE = new PhaseId("ANY_PHASE", i++);
 47  2
         list.add(ANY_PHASE);
 48  2
         RESTORE_VIEW = new PhaseId("RESTORE_VIEW", i++);
 49  2
         list.add(RESTORE_VIEW);
 50  2
         APPLY_REQUEST_VALUES = new PhaseId("APPLY_REQUEST_VALUES", i++);
 51  2
         list.add(APPLY_REQUEST_VALUES);
 52  2
         PROCESS_VALIDATIONS = new PhaseId("PROCESS_VALIDATIONS", i++);
 53  2
         list.add(PROCESS_VALIDATIONS);
 54  2
         UPDATE_MODEL_VALUES = new PhaseId("UPDATE_MODEL_VALUES", i++);
 55  2
         list.add(UPDATE_MODEL_VALUES);
 56  2
         INVOKE_APPLICATION = new PhaseId("INVOKE_APPLICATION", i++);
 57  2
         list.add(INVOKE_APPLICATION);
 58  2
         RENDER_RESPONSE = new PhaseId("RENDER_RESPONSE", i++);
 59  2
         list.add(RENDER_RESPONSE);
 60  2
         VALUES = Collections.unmodifiableList(list);
 61  2
     }
 62  
 
 63  
     private final String _name;
 64  
     private final int _ordinal;
 65  
 
 66  
     // CONSTRUCTORS
 67  
     private PhaseId(String name, int ordinal)
 68  14
     {
 69  14
         this._name = name;
 70  14
         this._ordinal = ordinal;
 71  14
     }
 72  
 
 73  
     // METHODS
 74  
     public int compareTo(Object other)
 75  
     {
 76  0
         return _ordinal - ((PhaseId) other)._ordinal;
 77  
     }
 78  
 
 79  
     public int getOrdinal()
 80  
     {
 81  0
         return _ordinal;
 82  
     }
 83  
 
 84  
     @Override
 85  
     public String toString()
 86  
     {
 87  2
         return _name + "(" + _ordinal + ")";
 88  
     }
 89  
     
 90  
     /*
 91  
      * @since 2.2
 92  
      */
 93  
     public String getName()
 94  
     {
 95  0
         return this._name;
 96  
     }
 97  
 
 98  
     public static PhaseId phaseIdValueOf(String phase)
 99  
     {
 100  0
         if (phase == null)
 101  
         {
 102  0
             throw new NullPointerException("phase");
 103  
         }
 104  0
         for (int i = 0; i < VALUES.size(); i++)
 105  
         {
 106  0
             PhaseId phaseId = VALUES.get(i);
 107  0
             if (phaseId.getName().equals(phase))
 108  
             {
 109  0
                 return phaseId;
 110  
             }
 111  
         }
 112  0
         throw new FacesException("Phase "+phase+" is invalid");
 113  
     }
 114  
 }