001: /*
002: * Copyright 2004 The Apache Software Foundation.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package javax.faces.event;
017:
018: import javax.faces.context.FacesContext;
019: import javax.faces.lifecycle.Lifecycle;
020: import java.util.EventObject;
021:
022: /**
023: * see Javadoc of <a href="http://java.sun.com/javaee/javaserverfaces/1.2/docs/api/index.html">JSF Specification</a>
024: *
025: * @author Thomas Spiegl (latest modification by $Author: mbr $)
026: * @version $Revision: 515800 $ $Date: 2007-03-07 23:06:59 +0100 (Mi, 07 Mrz 2007) $
027: */
028: public class PhaseEvent extends EventObject {
029: private static final long serialVersionUID = -7235692965954486239L;
030: // FIELDS
031: private FacesContext _facesContext;
032: private PhaseId _phaseId;
033:
034: // CONSTRUCTORS
035: public PhaseEvent(FacesContext facesContext, PhaseId phaseId,
036: Lifecycle lifecycle) {
037: super (lifecycle);
038: if (facesContext == null)
039: throw new NullPointerException("facesContext");
040: if (phaseId == null)
041: throw new NullPointerException("phaseId");
042: if (lifecycle == null)
043: throw new NullPointerException("lifecycle");
044:
045: _facesContext = facesContext;
046: _phaseId = phaseId;
047: }
048:
049: // METHODS
050: public FacesContext getFacesContext() {
051: return _facesContext;
052: }
053:
054: public PhaseId getPhaseId() {
055: return _phaseId;
056: }
057:
058: @Override
059: public int hashCode() {
060: final int PRIME = 31;
061: int result = 1;
062: result = PRIME * result
063: + ((source == null) ? 0 : source.hashCode());
064: result = PRIME
065: * result
066: + ((_facesContext == null) ? 0 : _facesContext
067: .hashCode());
068: result = PRIME * result
069: + ((_phaseId == null) ? 0 : _phaseId.hashCode());
070: return result;
071: }
072:
073: @Override
074: public boolean equals(Object obj) {
075: if (this == obj)
076: return true;
077: if (obj == null)
078: return false;
079: if (getClass() != obj.getClass())
080: return false;
081: final PhaseEvent other = (PhaseEvent) obj;
082: if (source == null) {
083: if (other.source != null)
084: return false;
085: } else if (!source.equals(other.source))
086: return false;
087: if (_facesContext == null) {
088: if (other._facesContext != null)
089: return false;
090: } else if (!_facesContext.equals(other._facesContext))
091: return false;
092: if (_phaseId == null) {
093: if (other._phaseId != null)
094: return false;
095: } else if (!_phaseId.equals(other._phaseId))
096: return false;
097: return true;
098: }
099:
100: }
|