@Override public int hashCode() { final HashCodeBuilder hcb = new HashCodeBuilder(); hcb.append(getIndex()); if (getRechnungsPosition() != null) { hcb.append(getRechnungsPositionId()); } if (getEingangsrechnungsPosition() != null) { hcb.append(getEingangsrechnungsPositionId()); } if (getEmployeeSalary() != null) { hcb.append(getEmployeeSalaryId()); } return hcb.toHashCode(); }
/** * Only the last entry of cost assignments is deletable if not already persisted (no id/pk given). * * @param zuweisung * @return */ public boolean isKostZuweisungDeletable(final KostZuweisungDO zuweisung) { if (zuweisung == null) { return false; } if (this instanceof EingangsrechnungsPositionDO && Objects.equals(zuweisung.getEingangsrechnungsPositionId(), this.getId()) == false || this instanceof RechnungsPositionDO && Objects.equals(zuweisung.getRechnungsPositionId(), this.getId()) == false) { log.error("Oups, given cost assignment is not assigned to this invoice position."); return false; } if (zuweisung.getId() != null) { return false; } // if (zuweisung.getIndex() + 1 < this.kostZuweisungen.size()) { // return false; // } return true; }
/** * If empty then no error will be returned. * * @return error message (i18n key) or null if no error is given. */ @Transient public String hasErrors() { if (isEmpty() == true) { return null; } int counter = 0; if (getRechnungsPositionId() != null) { counter++; } if (getEingangsrechnungsPositionId() != null) { counter++; } if (getEmployeeSalaryId() != null) { counter++; } if (counter != 1) { return "fibu.kostZuweisung.error.genauEinFinanzobjektErwartet"; // i18n key } return null; }
@Override public boolean equals(final Object o) { if (o instanceof KostZuweisungDO) { final KostZuweisungDO other = (KostZuweisungDO) o; if (ObjectUtils.equals(this.getIndex(), other.getIndex()) == false) { return false; } if (ObjectUtils.equals(this.getRechnungsPositionId(), other.getRechnungsPositionId()) == false) { return false; } if (ObjectUtils.equals(this.getEingangsrechnungsPositionId(), other.getEingangsrechnungsPositionId()) == false) { return false; } if (ObjectUtils.equals(this.getEmployeeSalaryId(), other.getEmployeeSalaryId()) == false) { return false; } return true; } return false; }