Coverage Report - javax.faces.event.PhaseId
 
Classes in this File Line Coverage Branch Coverage Complexity
PhaseId
85%
28/33
50%
4/8
2.2
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package javax.faces.event;
 17  
 
 18  
 import java.util.ArrayList;
 19  
 import java.util.Collections;
 20  
 import java.util.List;
 21  
 
 22  
 /**
 23  
  * @author shot
 24  
  */
 25  
 public class PhaseId {
 26  
 
 27  
     public static final PhaseId ANY_PHASE;
 28  
 
 29  
     public static final PhaseId APPLY_REQUEST_VALUES;
 30  
 
 31  
     public static final PhaseId INVOKE_APPLICATION;
 32  
 
 33  
     public static final PhaseId PROCESS_VALIDATIONS;
 34  
 
 35  
     public static final PhaseId RENDER_RESPONSE;
 36  
 
 37  
     public static final PhaseId RESTORE_VIEW;
 38  
 
 39  
     public static final PhaseId UPDATE_MODEL_VALUES;
 40  
 
 41  
     private static final String ANY_PHASE_NAME = "ANY_PHASE";
 42  
 
 43  
     private static final String RESTORE_VIEW_NAME = "RESTORE_VIEW";
 44  
 
 45  
     private static final String APPLY_REQUEST_VALUES_NAME = "APPLY_REQUEST_VALUES";
 46  
 
 47  
     private static final String PROCESS_VALIDATIONS_NAME = "PROCESS_VALIDATIONS";
 48  
 
 49  
     private static final String UPDATE_MODEL_VALUES_NAME = "UPDATE_MODEL_VALUES";
 50  
 
 51  
     private static final String INVOKE_APPLICATIONS_NAME = "INVOKE_APPLICATIONS";
 52  
 
 53  
     private static final String RENDER_RESPONSE_NAME = "RENDER_RESPONSE";
 54  
 
 55  
     public static final List VALUES;
 56  
 
 57  
     private final String name;
 58  
 
 59  
     private final int ordinal;
 60  
 
 61  
     static {
 62  1
         int i = 0;
 63  1
         List list = new ArrayList();
 64  
 
 65  1
         ANY_PHASE = new PhaseId(ANY_PHASE_NAME, i++);
 66  1
         RESTORE_VIEW = new PhaseId(RESTORE_VIEW_NAME, i++);
 67  1
         APPLY_REQUEST_VALUES = new PhaseId(APPLY_REQUEST_VALUES_NAME, i++);
 68  1
         PROCESS_VALIDATIONS = new PhaseId(PROCESS_VALIDATIONS_NAME, i++);
 69  1
         UPDATE_MODEL_VALUES = new PhaseId(UPDATE_MODEL_VALUES_NAME, i++);
 70  1
         INVOKE_APPLICATION = new PhaseId(INVOKE_APPLICATIONS_NAME, i++);
 71  1
         RENDER_RESPONSE = new PhaseId(RENDER_RESPONSE_NAME, i++);
 72  
 
 73  1
         list.add(ANY_PHASE);
 74  1
         list.add(RESTORE_VIEW);
 75  1
         list.add(APPLY_REQUEST_VALUES);
 76  1
         list.add(PROCESS_VALIDATIONS);
 77  1
         list.add(UPDATE_MODEL_VALUES);
 78  1
         list.add(INVOKE_APPLICATION);
 79  1
         list.add(RENDER_RESPONSE);
 80  
 
 81  1
         VALUES = Collections.unmodifiableList(list);
 82  1
     }
 83  
 
 84  7
     private PhaseId(String name, int ordinal) {
 85  7
         this.name = name;
 86  7
         this.ordinal = ordinal;
 87  7
     }
 88  
 
 89  
     public int compareTo(Object o) {
 90  0
         return ordinal - ((PhaseId) o).ordinal;
 91  
     }
 92  
 
 93  
     public int getOrdinal() {
 94  92
         return ordinal;
 95  
     }
 96  
 
 97  
     public String toString() {
 98  0
         return name + ":" + ordinal;
 99  
     }
 100  
 
 101  
     public boolean equals(Object obj) {
 102  21
         if (obj == null) {
 103  0
             return false;
 104  
         }
 105  21
         if (!(obj instanceof PhaseId)) {
 106  0
             return false;
 107  
         }
 108  21
         PhaseId other = (PhaseId) obj;
 109  21
         if (this.ordinal == other.ordinal && this.name.equals(other.name)) {
 110  21
             return true;
 111  
         }
 112  0
         return false;
 113  
     }
 114  
 
 115  
 }