001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2004-2006, Geotools Project Managment Committee (PMC)
005: * (C) 2004 TOPP - www.openplans.org
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation; either
010: * version 2.1 of the License, or (at your option) any later version.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * Created on Jan 14, 2004
018: */
019: package org.geotools.validation.dto;
020:
021: import java.util.HashMap;
022: import java.util.Iterator;
023: import java.util.Map;
024:
025: /**
026: * TestSuiteConfig purpose.
027: *
028: * <p>
029: * Description of TestSuiteConfig ...
030: * </p>
031: *
032: * @author dzwiers, Refractions Research, Inc.
033: * @author $Author: dmzwiers $ (last modification)
034: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/extension/validation/src/main/java/org/geotools/validation/dto/TestSuiteDTO.java $
035: * @version $Id: TestSuiteDTO.java 20884 2006-08-07 14:10:46Z jgarnett $
036: */
037: public class TestSuiteDTO {
038: /** the test suite name */
039: private String name;
040:
041: /** the test suite description */
042: private String description;
043:
044: /** the list of tests */
045: private Map tests;
046:
047: /**
048: * TestSuiteConfig constructor.
049: *
050: * <p>
051: * Does nothing
052: * </p>
053: */
054: public TestSuiteDTO() {
055: }
056:
057: /**
058: * TestSuiteConfig constructor.
059: *
060: * <p>
061: * Creates a copy of the TestSuiteConfig passed in.
062: * </p>
063: *
064: * @param ts The Test Suite to copy
065: */
066: public TestSuiteDTO(TestSuiteDTO ts) {
067: name = ts.getName();
068: description = ts.getDescription();
069: tests = new HashMap();
070:
071: Iterator i = ts.getTests().keySet().iterator();
072:
073: while (i.hasNext()) {
074: TestDTO t = (TestDTO) ts.getTests().get(i.next());
075: tests.put(t.getName(), new TestDTO(t));
076: }
077: }
078:
079: /**
080: * Implementation of clone.
081: *
082: * @return An instance of TestSuiteConfig.
083: *
084: * @see java.lang.Object#clone()
085: */
086: public Object clone() {
087: return new TestSuiteDTO(this );
088: }
089:
090: public int hashCode() {
091: int r = 1;
092:
093: if (tests != null) {
094: r *= tests.hashCode();
095: }
096:
097: if (name != null) {
098: r *= name.hashCode();
099: }
100:
101: if (description != null) {
102: r *= description.hashCode();
103: }
104:
105: return r;
106: }
107:
108: /**
109: * Implementation of equals.
110: *
111: * @param obj An object to compare for equality.
112: *
113: * @return true when the objects have the same data in the same order.
114: *
115: * @see java.lang.Object#equals(java.lang.Object)
116: */
117: public boolean equals(Object obj) {
118: if ((obj == null) || !(obj instanceof TestSuiteDTO)) {
119: return false;
120: }
121:
122: boolean r = true;
123: TestSuiteDTO ts = (TestSuiteDTO) obj;
124:
125: if (name != null) {
126: r = r && (name.equals(ts.getName()));
127: }
128:
129: if (description != null) {
130: r = r && (description.equals(ts.getDescription()));
131: }
132:
133: if (tests == null) {
134: if (ts.getTests() != null) {
135: return false;
136: }
137: } else {
138: if (ts.getTests() != null) {
139: r = r && tests.equals(ts.getTests());
140: } else {
141: return false;
142: }
143: }
144:
145: return r;
146: }
147:
148: /**
149: * Access description property.
150: *
151: * @return Returns the description.
152: */
153: public String getDescription() {
154: return description;
155: }
156:
157: /**
158: * Set description to description.
159: *
160: * @param description The description to set.
161: */
162: public void setDescription(String description) {
163: this .description = description;
164: }
165:
166: /**
167: * Access name property.
168: *
169: * @return Returns the name.
170: */
171: public String getName() {
172: return name;
173: }
174:
175: /**
176: * Set name to name.
177: *
178: * @param name The name to set.
179: */
180: public void setName(String name) {
181: this .name = name;
182: }
183:
184: /**
185: * Access tests property.
186: *
187: * @return Returns the tests.
188: */
189: public Map getTests() {
190: return tests;
191: }
192:
193: /**
194: * Set tests to tests.
195: *
196: * @param tests The tests to set.
197: */
198: public void setTests(Map tests) {
199: this.tests = tests;
200: }
201: }
|