View Javadoc

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 jakarta.faces.event;
20  
21  import jakarta.faces.lifecycle.Lifecycle;
22  import jakarta.faces.context.FacesContext;
23  
24  import java.util.EventObject;
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 PhaseEvent extends EventObject
30  {
31      private static final long serialVersionUID = -7235692965954486239L;
32      // FIELDS
33      private FacesContext _facesContext;
34      private PhaseId _phaseId;
35  
36      // CONSTRUCTORS
37      public PhaseEvent(FacesContext facesContext, PhaseId phaseId, Lifecycle lifecycle)
38      {
39          super(lifecycle);
40          if (facesContext == null)
41          {
42              throw new NullPointerException("facesContext");
43          }
44          if (phaseId == null)
45          {
46              throw new NullPointerException("phaseId");
47          }
48          if (lifecycle == null)
49          {
50              throw new NullPointerException("lifecycle");
51          }
52  
53          _facesContext = facesContext;
54          _phaseId = phaseId;
55      }
56  
57      // METHODS
58      public FacesContext getFacesContext()
59      {
60          return _facesContext;
61      }
62  
63      public PhaseId getPhaseId()
64      {
65          return _phaseId;
66      }
67  
68      @Override
69      public int hashCode()
70      {
71          int prime = 31;
72          int result = 1;
73          result = prime * result + ((source == null) ? 0 : source.hashCode());
74          result = prime * result + ((_facesContext == null) ? 0 : _facesContext.hashCode());
75          result = prime * result + ((_phaseId == null) ? 0 : _phaseId.hashCode());
76          return result;
77      }
78  
79      @Override
80      public boolean equals(Object obj)
81      {
82          if (this == obj)
83          {
84              return true;
85          }
86          if (obj == null)
87          {
88              return false;
89          }
90          if (getClass() != obj.getClass())
91          {
92              return false;
93          }
94          PhaseEvent other = (PhaseEvent) obj;
95          if (source == null)
96          {
97              if (other.source != null)
98              {
99                  return false;
100             }
101         }
102         else if (!source.equals(other.source))
103         {
104             return false;
105         }
106         if (_facesContext == null)
107         {
108             if (other._facesContext != null)
109             {
110                 return false;
111             }
112         }
113         else if (!_facesContext.equals(other._facesContext))
114         {
115             return false;
116         }
117         if (_phaseId == null)
118         {
119             if (other._phaseId != null)
120             {
121                 return false;
122             }
123         }
124         else if (!_phaseId.equals(other._phaseId))
125         {
126             return false;
127         }
128         return true;
129     }
130 
131 }