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 Hibernate3sNestEx {
010: public Hibernate3sNestEx() {
011: }
012:
013: public Hibernate3sNestEx(Integer id) {
014: this .id = id;
015: }
016:
017: public Hibernate3sNestEx(Integer id, String name) {
018: this .id = id;
019: this .name = name;
020: }
021:
022: public Hibernate3sNestEx(Integer id, String name,
023: Hibernate3sEx owner) {
024: this .id = id;
025: this .name = name;
026: this .owner = owner;
027: }
028:
029: public Integer getId() {
030: return id;
031: }
032:
033: public void setId(Integer id) {
034: this .id = id;
035: }
036:
037: public String getName() {
038: return name;
039: }
040:
041: public void setName(String name) {
042: this .name = name;
043: }
044:
045: public Hibernate3sEx getOwner() {
046: return owner;
047: }
048:
049: public void setOwner(Hibernate3sEx owner) {
050: this .owner = owner;
051: }
052:
053: @Override
054: public String toString() {
055: if (owner == null) {
056: return "Hibernate3sNestEx[id=" + getId() + ",name="
057: + getName() + ",owner=null]";
058: } else {
059: return "Hibernate3sNestEx[id=" + getId() + ",name="
060: + getName() + ",owner=" + getOwner().getName()
061: + "]";
062: }
063: }
064:
065: @Override
066: public boolean equals(Object obj) {
067: if (obj == null) {
068: return false;
069: }
070:
071: if (obj == this ) {
072: return true;
073: }
074:
075: Class<? extends Hibernate3sNestEx> this Class = this .getClass();
076: Class<? extends Object> thatClass = obj.getClass();
077: if (!this Class.isAssignableFrom(thatClass)
078: && !thatClass.isAssignableFrom(this Class)) {
079: return false;
080: }
081:
082: Hibernate3sNestEx that = (Hibernate3sNestEx) obj;
083:
084: if (!CompareUtil.equals(this .getId(), that.getId())) {
085: return false;
086: }
087:
088: // Normally .equals should only have to test PK for equality with a DB
089: // but we want our tests to be tighter ...
090:
091: if (!CompareUtil.equals(this .getName(), that.getName())) {
092: return false;
093: }
094:
095: // We don't want to recurse
096: // if (!CompareUtil.equals(this.getOwner(), that.getOwner()))
097: // {
098: // return false;
099: // }
100:
101: return true;
102: }
103:
104: private Integer id;
105:
106: private String name;
107:
108: private Hibernate3sEx owner;
109: }
|