1 57 package com.ivata.groupware.container.persistence; 58 59 import java.io.IOException ; 60 import java.io.ObjectInputStream ; 61 import java.io.ObjectOutputStream ; 62 import java.io.Serializable ; 63 64 import com.ivata.mask.util.StringHandling; 65 import com.ivata.mask.valueobject.ValueObject; 66 67 77 public abstract class BaseDO implements Serializable , ValueObject { 78 83 private Integer id; 84 85 88 public boolean equals(final Object compare) { 89 return hashCode() == compare.hashCode(); 90 } 91 92 101 public String getDisplayValue() { 102 throw new UnsupportedOperationException ( 103 "ERROR: getDisplayValue not implemented for " 104 + this.getClass()); 105 } 106 107 118 public Integer getId() { 119 return id; 120 } 121 122 134 public final String getIdString() { 135 return id == null ? null : id.toString(); 136 } 137 138 141 public int hashCode() { 142 String modifier = getClass().getName(); 143 int result = 17; 144 if (getId() == null) { 145 result = 37 * result; 146 } else { 147 result = 37 * result + (int) getId().hashCode(); 148 } 149 result = 37 * result + (int) modifier.hashCode(); 150 return result; 151 } 152 153 162 private void readObject(final ObjectInputStream ois) 163 throws ClassNotFoundException , IOException { 164 ois.defaultReadObject(); 165 } 166 167 174 public final void setId(final Integer id) { 175 this.id = id; 176 } 177 183 public final void setIdString(final String idString) { 184 id = StringHandling.integerValue(idString); 185 } 186 187 188 195 public String toString() { 196 String className = getClass().getName(); 197 if (className.lastIndexOf('.') >= 0) { 199 className = className.substring(className.lastIndexOf('.') + 1); 200 } 201 return className 202 + "(id " 203 + getId() 204 + ")"; 205 } 206 207 213 private void writeObject(final ObjectOutputStream oos) throws IOException { 214 oos.defaultWriteObject(); 215 } 216 } 217 | Popular Tags |