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.concreteiteration;
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.iteration.Iteration;
026:
027: /**
028: *
029: * A ConcreteIteration is a specific {@link Iteration} for a {@link Project}.
030: *
031: */
032: public class ConcreteIteration extends ConcreteActivity implements
033: Cloneable {
034:
035: private Iteration iteration;
036:
037: /**
038: * Default class constructor.
039: */
040: public ConcreteIteration() {
041: super ();
042: }
043:
044: /**
045: * Returns a copy of the current instance of ConcreteIteration
046: *
047: * @return a copy of the ConcreteIteration
048: * @throws CloneNotSupportedException
049: */
050: @Override
051: public ConcreteIteration clone() throws CloneNotSupportedException {
052: ConcreteIteration concreteIteration = new ConcreteIteration();
053: concreteIteration.copy(this );
054: return concreteIteration;
055: }
056:
057: /**
058: * Copy the values of the specified ConcreteIteration into the current
059: * instance.
060: *
061: * @param _iteration
062: * the ConcreteIteration to copy.
063: */
064: protected void copy(final ConcreteIteration _concreteIteration) {
065: super .copy(_concreteIteration);
066: this .iteration = _concreteIteration.getIteration();
067: }
068:
069: /**
070: * Defines if the specified Object is the same or has the same values as the
071: * current instance of the class.
072: *
073: * @param obj
074: * the Object to be compare to the ConcreteIteration
075: * @return true if the specified Object is the same, false otherwise
076: */
077: public boolean equals(Object obj) {
078: if (obj instanceof ConcreteIteration == false) {
079: return false;
080: }
081: if (this == obj) {
082: return true;
083: }
084: ConcreteIteration concreteIteration = (ConcreteIteration) obj;
085: return new EqualsBuilder().appendSuper(
086: super .equals(concreteIteration)).append(this .iteration,
087: concreteIteration.iteration).isEquals();
088: }
089:
090: /**
091: * Returns a hash code value for the object. This method is supported for
092: * the benefit of hash tables.
093: *
094: * @return the hash code of the current instance of ConcreteIteration
095: */
096: public int hashCode() {
097: return new HashCodeBuilder(17, 37)
098: .appendSuper(super .hashCode()).append(this .iteration)
099: .toHashCode();
100: }
101:
102: /**
103: * Attach an Iteration to the ConcreteIteration
104: *
105: * @param _iteration
106: * the Iteration to be attached
107: */
108: public void addIteration(Iteration _iteration) {
109: this .iteration = _iteration;
110: _iteration.getConcreteIterations().add(this );
111: }
112:
113: /**
114: * Detach an Iteration from the Collection of the ConcreteIteration
115: *
116: * @param _iteration
117: * the Iteration to be detached
118: */
119: public void removeIteration(Iteration _iteration) {
120: _iteration.getConcreteIterations().remove(this );
121: this .iteration = null;
122: }
123:
124: /**
125: * Get the Iteration reattached to the ConcreteIteration
126: *
127: * @return the Iteration of the ConcreteIteration
128: */
129: public Iteration getIteration() {
130: return iteration;
131: }
132:
133: /**
134: * Set the Iteration reattached to the ConcreteIteration
135: *
136: * @param iteration
137: * the Iteration to be reattached to the ConcreteIteration
138: */
139: public void setIteration(Iteration iteration) {
140: this.iteration = iteration;
141: }
142: }
|