001: //$Id: ComplexVO.java 149 2005-05-26 22:13:10Z jg_hamburg $
002: /********************************************************************************
003: * DDTUnit, a Datadriven Approach to Unit- and Moduletesting
004: * Copyright (c) 2004, Joerg and Kai Gellien
005: * All rights reserved.
006: *
007: * The Software is provided under the terms of the Common Public License 1.0
008: * as provided with the distribution of DDTUnit in the file cpl-v10.html.
009: * Redistribution and use in source and binary forms, with or without
010: * modification, are permitted provided that the following conditions
011: * are met:
012: *
013: * + Redistributions of source code must retain the above copyright
014: * notice, this list of conditions and the following disclaimer.
015: *
016: * + Redistributions in binary form must reproduce the above
017: * copyright notice, this list of conditions and the following
018: * disclaimer in the documentation and/or other materials provided
019: * with the distribution.
020: *
021: * + Neither the name of the authors or DDTUnit, nor the
022: * names of its contributors may be used to endorse or promote
023: * products derived from this software without specific prior
024: * written permission.
025: *
026: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
027: * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
028: * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
029: * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
030: * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
031: * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
032: * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
033: * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
034: * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
035: * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
036: * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
037: ********************************************************************************/package junitx.ddtunit.resources;
038:
039: import java.util.List;
040: import java.util.Map;
041:
042: /**
043: * Test resource representing nested complex field structures.
044: *
045: * @author jg
046: */
047: public class ComplexVO {
048: private String text;
049:
050: private SimpleVO simpleVO;
051:
052: private List collect;
053:
054: private Map map;
055:
056: /**
057: * Default constructor
058: *
059: */
060: public ComplexVO() {
061: // no special initialization
062: }
063:
064: public ComplexVO(SimpleVO simpleVO) {
065: this .simpleVO = simpleVO;
066: }
067:
068: public ComplexVO(String text, List collect) {
069: this .text = text;
070: this .collect = collect;
071: }
072:
073: public String toString() {
074: StringBuffer sb = new StringBuffer("ComplexVO: text=\"")
075: .append(this .text).append("\", simpleVO=<").append(
076: this .simpleVO).append(">");
077: return sb.toString();
078: }
079:
080: public int hashCode() {
081: final int CONST_VAL = 42;
082: int hashVal = CONST_VAL + this .text.hashCode();
083: hashVal = (CONST_VAL * hashVal) + this .simpleVO.hashCode();
084: return hashVal;
085: }
086:
087: public SimpleVO getSimpleVO() {
088: return simpleVO;
089: }
090:
091: public void setBeanSimpleVO(SimpleVO simpleVO) {
092: this .simpleVO = simpleVO;
093: }
094:
095: public String getText() {
096: return text;
097: }
098:
099: public void setText(String text) {
100: this .text = text;
101: }
102:
103: /**
104: * Returns <code>true</code> if this <code>ComplexVO</code> is the same
105: * as the o argument.
106: *
107: * @return <code>true</code> if this <code>ComplexVO</code> is the same
108: * as the o argument.
109: */
110: public boolean equals(Object o) {
111: if (this == o) {
112: return true;
113: }
114: if (o == null) {
115: return false;
116: }
117: if (o.getClass() != getClass()) {
118: return false;
119: }
120: ComplexVO castedObj = (ComplexVO) o;
121: return ((this .text == null ? castedObj.text == null : this .text
122: .equals(castedObj.text))
123: && (this .simpleVO == null ? castedObj.simpleVO == null
124: : this .simpleVO.equals(castedObj.simpleVO)) && (this .collect == null ? castedObj.collect == null
125: : this .collect.equals(castedObj.collect)));
126: }
127:
128: public List getCollect() {
129: return collect;
130: }
131:
132: public void setCollect(List collect) {
133: this .collect = collect;
134: }
135:
136: public Map getMap() {
137: return this.map;
138: }
139: }
|