001: package org.directwebremoting.convert.mapped;
002:
003: import org.directwebremoting.util.CompareUtil;
004:
005: /**
006: * A hibernate bean to fit the declaration in {@link org.directwebremoting.hibernate.Database}
007: * @author Joe Walker [joe at getahead dot ltd dot uk]
008: */
009: public class Hibernate3NestEx {
010: public Hibernate3NestEx() {
011: }
012:
013: public Hibernate3NestEx(Integer id) {
014: this .id = id;
015: }
016:
017: public Hibernate3NestEx(Integer id, String name) {
018: this .id = id;
019: this .name = name;
020: }
021:
022: public Hibernate3NestEx(Integer id, String name, Hibernate3Ex owner) {
023: this .id = id;
024: this .name = name;
025: this .owner = owner;
026: }
027:
028: public Integer getId() {
029: return id;
030: }
031:
032: public void setId(Integer id) {
033: this .id = id;
034: }
035:
036: public String getName() {
037: return name;
038: }
039:
040: public void setName(String name) {
041: this .name = name;
042: }
043:
044: public Hibernate3Ex getOwner() {
045: return owner;
046: }
047:
048: public void setOwner(Hibernate3Ex owner) {
049: this .owner = owner;
050: }
051:
052: @Override
053: public String toString() {
054: if (owner == null) {
055: return "Hibernate3NestEx[id=" + getId() + ",name="
056: + getName() + ",owner=null]";
057: } else {
058: return "Hibernate3NestEx[id=" + getId() + ",name="
059: + getName() + ",owner=" + getOwner().getName()
060: + "]";
061: }
062: }
063:
064: @Override
065: public boolean equals(Object obj) {
066: if (obj == null) {
067: return false;
068: }
069:
070: if (obj == this ) {
071: return true;
072: }
073:
074: Class<? extends Hibernate3NestEx> this Class = this .getClass();
075: Class<? extends Object> thatClass = obj.getClass();
076: if (!this Class.isAssignableFrom(thatClass)
077: && !thatClass.isAssignableFrom(this Class)) {
078: return false;
079: }
080:
081: Hibernate3NestEx that = (Hibernate3NestEx) obj;
082:
083: if (!CompareUtil.equals(this .getId(), that.getId())) {
084: return false;
085: }
086:
087: // Normally .equals should only have to test PK for equality with a DB
088: // but we want our tests to be tighter ...
089:
090: if (!CompareUtil.equals(this .getName(), that.getName())) {
091: return false;
092: }
093:
094: // We don't want to recurse
095: // if (!CompareUtil.equals(this.getOwner(), that.getOwner()))
096: // {
097: // return false;
098: // }
099:
100: return true;
101: }
102:
103: private Integer id;
104:
105: private String name;
106:
107: private Hibernate3Ex owner;
108: }
|