@Override public int hashCode() { final int prime = 811; int hashCode = super.hashCode(); if (isSetModifiedDate()) { hashCode += prime * getModifiedDate().hashCode(); } if (isSetCreatedDate()) { hashCode += prime * getCreatedDate().hashCode(); } return hashCode; }
/** * 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 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; }
/** * Checks whether at least one attribute has been set for this * {@link History}. * * @return {@code true} if at least one of the possible attributes is set, i.e., not * null: * <ul> * <li> {@link #creation} date</li> * <li> {@link #listOfCreators} is not null and contains at least one * element</li> * <li> * {@link #listOfModification} is not null and contains at least one * element.</li> * <li> {@link #modified} is not {@code null}.</li> * </ul> */ public boolean isEmpty() { return !isSetCreatedDate() && !isSetListOfCreators() && !isSetListOfModification() && !isSetModifiedDate(); }
else if (contextObject.getHistory().isSetCreatedDate())
if (history.isSetCreatedDate())
(contextObject.getHistory().isSetCreatedDate() || contextObject.getHistory().isSetModifiedDate()))