001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software 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: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.test.xml.immutable;
023:
024: import java.util.Collection;
025:
026: /**
027: * @author <a href="mailto:alex@jboss.org">Alexey Loubyansky</a>
028: * @version <tt>$Revision: 57211 $</tt>
029: */
030: public class Parent {
031: private final Child1 child1;
032: private final Collection child2;
033: private final Collection otherChildren;
034: private final Collection immutableChoice;
035:
036: public Parent(Child1 child1, Collection child2,
037: Collection otherChildren, Collection immutableChoice) {
038: this .child1 = child1;
039: this .child2 = child2;
040: this .otherChildren = otherChildren;
041: this .immutableChoice = immutableChoice;
042: }
043:
044: public Child1 getChild1() {
045: return child1;
046: }
047:
048: public Collection getChild2() {
049: return child2;
050: }
051:
052: public Collection getOtherChildren() {
053: return otherChildren;
054: }
055:
056: public Collection getImmutableChoice() {
057: return immutableChoice;
058: }
059:
060: public boolean equals(Object o) {
061: if (this == o) {
062: return true;
063: }
064: if (!(o instanceof Parent)) {
065: return false;
066: }
067:
068: final Parent parent = (Parent) o;
069:
070: if (child1 != null ? !child1.equals(parent.child1)
071: : parent.child1 != null) {
072: return false;
073: }
074: if (child2 != null ? !child2.equals(parent.child2)
075: : parent.child2 != null) {
076: return false;
077: }
078: if (immutableChoice != null ? !immutableChoice
079: .equals(parent.immutableChoice)
080: : parent.immutableChoice != null) {
081: return false;
082: }
083: if (otherChildren != null ? !otherChildren
084: .equals(parent.otherChildren)
085: : parent.otherChildren != null) {
086: return false;
087: }
088:
089: return true;
090: }
091:
092: public int hashCode() {
093: int result;
094: result = (child1 != null ? child1.hashCode() : 0);
095: result = 29 * result + (child2 != null ? child2.hashCode() : 0);
096: result = 29
097: * result
098: + (otherChildren != null ? otherChildren.hashCode() : 0);
099: result = 29
100: * result
101: + (immutableChoice != null ? immutableChoice.hashCode()
102: : 0);
103: return result;
104: }
105:
106: public String toString() {
107: return "[child1=" + child1 + ", child2=" + child2
108: + ", otherChildren=" + otherChildren
109: + ", immutableChoice=" + immutableChoice + "]";
110: }
111: }
|