@Override public int hashCode() { if (this.getId() != StudyImpl.UNSAVED_ID) { return (int) getId(); } else { final int PRIME = 37; int hashcode = 1; if (getName() != null) hashcode = PRIME * hashcode + getName().hashCode(); if (getAlias() != null) hashcode = PRIME * hashcode + getAlias().hashCode(); return hashcode; } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getName()); sb.append(" : "); sb.append(getAlias()); sb.append(" : "); sb.append(getDescription()); sb.append(" : "); sb.append(getStudyType()); sb.append(" : "); if (getProject() != null) { sb.append(getProject().getAlias()); sb.append("(" + getProject().getName() + ")"); } return sb.toString(); }
/** * Equivalency is based on getProjectId() if set, otherwise on name, description and creation date. */ @Override public boolean equals(Object obj) { if (obj == null) return false; if (obj == this) return true; if (!(obj instanceof Study)) return false; Study them = (Study) obj; // If not saved, then compare resolved actual objects. Otherwise // just compare IDs. if (getId() == StudyImpl.UNSAVED_ID || them.getId() == StudyImpl.UNSAVED_ID) { if (getName() != null && them.getName() != null) { return getName().equals(them.getName()); } else { return getAlias().equals(them.getAlias()); } } else { return this.getId() == them.getId(); } }
@Override public String getDeleteDescription() { Project p = getProject(); return (p.getShortName() == null ? p.getAlias() : p.getShortName()) + " " + getName() + " (" + getAlias() + ")"; }