/** * Clones the object Makes a deep copy of the Valivalues form references are set to null; * * @return */ public Object clone() throws CloneNotSupportedException { Question copy = null; copy = (Question) super.clone(); // make the copy a little deeper if (getValidValues() != null) { List validValuesCopy = new ArrayList(); ListIterator it = getValidValues().listIterator(); while (it.hasNext()) { FormValidValue validValue = (FormValidValue) it.next(); FormValidValue clonedValidValue = (FormValidValue) validValue.clone(); clonedValidValue.setQuestion(copy); validValuesCopy.add(clonedValidValue); } copy.setValidValues(validValuesCopy); copy.setForm(null); copy.setModule(null); } if (getInstructions() != null) { List instructionsCopy = new ArrayList(); ListIterator it = getInstructions().listIterator(); while (it.hasNext()) { Instruction instr = (Instruction) it.next(); Instruction instrClone = (Instruction) instr.clone(); instructionsCopy.add(instrClone); } copy.setInstructions(instructionsCopy); } return copy; }
/** * This equals method only compares the Idseq to define equals * * @param obj * @return */ public boolean equals(Object obj) { if (obj == null) return false; if (!(obj instanceof Question)) return false; Question question = (Question) obj; if (question.getQuesIdseq().equals(this.getQuesIdseq())) { return true; } return false; }