/** * Creates a {@link History} instance from a given {@link History}. * * @param history */ public History(History history) { super(history); listOfCreators = new ArrayList<Creator>(); for (Creator c : history.getListOfCreators()) { listOfCreators.add(c.clone()); } listOfModification = new ArrayList<Date>(); for (Date d : history.getListOfModifiedDates()) { listOfModification.add((Date) d.clone()); } Calendar calendar = Calendar.getInstance(); if (history.isSetCreatedDate()) { calendar.setTime(history.getCreatedDate()); creation = calendar.getTime(); } if (history.isSetModifiedDate()) { calendar.setTime(history.getModifiedDate()); modified = calendar.getTime(); } }
@Override public TreeNode getChildAt(int childIndex) { int pos = 0; if (isSetListOfCreators()) { if (pos == childIndex) { return new TreeNodeAdapter(getListOfCreators(), this); } pos++; } if (isSetListOfModification()) { if (pos == childIndex) { return new TreeNodeAdapter(getListOfModifiedDates(), this); } pos++; } throw new IndexOutOfBoundsException(MessageFormat.format( resourceBundle.getString("IndexExceedsBoundsException"), childIndex, Math.min(pos, 0))); }
@Override public boolean equals(Object object) { // Check all child elements recursively in super class first: boolean equals = super.equals(object); if (equals) { // Cast is possible because super class checks the class attributes History mh = (History) object; equals &= listOfCreators.size() == mh.getListOfCreators().size(); equals &= isSetModifiedDate() == mh.isSetModifiedDate(); if (equals && isSetModifiedDate()) { equals &= getModifiedDate().equals(mh.getModifiedDate()); } equals &= isSetCreatedDate() == mh.isSetCreatedDate(); // isSetCreatedDate() may still be null. if (equals && isSetCreatedDate()) { equals &= getCreatedDate().equals(mh.getCreatedDate()); } } return equals; }
int i = 0; for (Creator creator : history.getListOfCreators())