001: /*
002: * Wilos Is a cLever process Orchestration Software - http://www.wilos-project.org
003: * Copyright (C) 2006-2007 Paul Sabatier University, IUP ISI (Toulouse, France) <massie@irit.fr>
004: * Copyright (C) 2007 Mathieu BENOIT <mathieu-benoit@hotmail.fr>
005: *
006: * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
007: * General Public License as published by the Free Software Foundation; either version 2 of the License,
008: * or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
011: * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
012: * GNU General Public License for more details.
013: *
014: * You should have received a copy of the GNU General Public License along with this program; if not,
015: * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
016: */
017:
018: package wilos.model.misc.concretephase;
019:
020: import org.apache.commons.lang.builder.EqualsBuilder;
021: import org.apache.commons.lang.builder.HashCodeBuilder;
022:
023: import wilos.model.misc.concreteactivity.ConcreteActivity;
024: import wilos.model.misc.project.Project;
025: import wilos.model.spem2.phase.Phase;
026:
027: /**
028: *
029: * A ConcretePhase is a specific {@link Phase} for a {@link Project}.
030: *
031: */
032: public class ConcretePhase extends ConcreteActivity implements
033: Cloneable {
034:
035: private Phase phase;
036:
037: /**
038: * Default class constructor
039: */
040: public ConcretePhase() {
041: super ();
042: }
043:
044: /**
045: * Returns a copy of the current instance of ConcretePhase
046: *
047: * @return a copy of the ConcretePhase
048: * @throws CloneNotSupportedException
049: */
050: @Override
051: public ConcretePhase clone() throws CloneNotSupportedException {
052: ConcretePhase concretePhase = new ConcretePhase();
053: concretePhase.copy(this );
054: return concretePhase;
055: }
056:
057: /**
058: * Copy the values of the specified ConcretePhase into the current instance.
059: *
060: * @param _cnocretePhase
061: * The concretePhase to copy.
062: */
063: protected void copy(final ConcretePhase _concretePhase) {
064: super .copy(_concretePhase);
065: this .phase = _concretePhase.getPhase();
066: }
067:
068: /**
069: * Defines if the specified Object is the same or has the same values as the
070: * current instance of the class.
071: *
072: * @param obj
073: * the Object to be compare to the ConcretePhase
074: * @return true if the specified Object is the same, false otherwise
075: */
076: public boolean equals(Object obj) {
077: if (obj instanceof ConcretePhase == false) {
078: return false;
079: }
080: if (this == obj) {
081: return true;
082: }
083: ConcretePhase concretePhase = (ConcretePhase) obj;
084: return new EqualsBuilder().appendSuper(
085: super .equals(concretePhase)).append(this .phase,
086: concretePhase.phase).isEquals();
087: }
088:
089: /**
090: * Returns a hash code value for the object. This method is supported for
091: * the benefit of hash tables.
092: *
093: * @return the hash code of the current instance of ConcretePhase
094: */
095: public int hashCode() {
096: return new HashCodeBuilder(17, 37)
097: .appendSuper(super .hashCode()).append(this .phase)
098: .toHashCode();
099: }
100:
101: /**
102: * Adds a relation between the current instance of ConcretePhase and the
103: * specified Phase.
104: *
105: * @param _phase
106: * the Phase to relate to the ConcretePhase
107: */
108: public void addPhase(Phase _phase) {
109: this .phase = _phase;
110: _phase.getConcretePhases().add(this );
111: }
112:
113: /**
114: * Removes the relation between the current instance of ConcretePhase and
115: * the specified Phase.
116: *
117: * @param _phase
118: * the Phase to unlinked from the ConcretePhase
119: */
120: public void removePhase(Phase _phase) {
121: _phase.getConcretePhases().remove(this );
122: this .phase = null;
123:
124: }
125:
126: /**
127: * Returns the Phase assigned to the ConcretePhase.
128: *
129: * @return the Phase of the ConcretePhase
130: */
131: public Phase getPhase() {
132: return phase;
133: }
134:
135: /**
136: * Initializes the Phase of the ConcretePhase.
137: *
138: * @param phase
139: * the phase to set
140: */
141: public void setPhase(Phase phase) {
142: this.phase = phase;
143: }
144:
145: }
|