diff --git a/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java b/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java index a60db0159..226f155c8 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java +++ b/lib/taskana-core/src/main/java/pro/taskana/KeyDomain.java @@ -1,5 +1,7 @@ package pro.taskana; +import java.util.Objects; + /** * This class encapsulates key - domain pairs for identification of workbaskets. * @@ -33,11 +35,7 @@ public class KeyDomain { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + ((key == null) ? 0 : key.hashCode()); - return result; + return Objects.hash(key, domain); } @Override @@ -48,29 +46,15 @@ public class KeyDomain { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } KeyDomain other = (KeyDomain) obj; - if (domain == null) { - if (other.domain != null) { - return false; - } - } else if (!domain.equals(other.domain)) { - return false; - } - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equals(other.key)) { - return false; - } - return true; + return Objects.equals(key, other.key) && Objects.equals(domain, other.domain); } @Override public String toString() { - return "KeyDomain [" + "key=" + this.key + ", domain=" + this.domain + "]"; + return "KeyDomain [key=" + key + ", domain=" + domain + "]"; } } diff --git a/lib/taskana-core/src/main/java/pro/taskana/ObjectReference.java b/lib/taskana-core/src/main/java/pro/taskana/ObjectReference.java index 986ba76cf..5313228c2 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/ObjectReference.java +++ b/lib/taskana-core/src/main/java/pro/taskana/ObjectReference.java @@ -1,5 +1,7 @@ package pro.taskana; +import java.util.Objects; + /** ObjectReference entity. */ public class ObjectReference { @@ -60,67 +62,27 @@ public class ObjectReference { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((company == null) ? 0 : company.hashCode()); - result = prime * result + ((system == null) ? 0 : system.hashCode()); - result = prime * result + ((systemInstance == null) ? 0 : systemInstance.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((value == null) ? 0 : value.hashCode()); - return result; + return Objects.hash(id, company, system, systemInstance, type, value); } @Override - public boolean equals(Object other) { - if (this == other) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (other == null) { + if (obj == null) { return false; } - if (!getClass().isAssignableFrom(other.getClass())) { + if (getClass() != obj.getClass()) { return false; } - ObjectReference o = (ObjectReference) other; - - if (id == null && o.id != null) { - return false; - } - if (id != null && !(id.equals(o.id))) { - return false; - } - if (company == null && o.company != null) { - return false; - } - if (company != null && !(company.equals(o.company))) { - return false; - } - if (system == null && o.system != null) { - return false; - } - if (system != null && !(system.equals(o.system))) { - return false; - } - if (systemInstance == null && o.systemInstance != null) { - return false; - } - if (systemInstance != null && !(systemInstance.equals(o.systemInstance))) { - return false; - } - if (type == null && o.type != null) { - return false; - } - if (type != null && !(type.equals(o.type))) { - return false; - } - if (value == null && o.value != null) { - return false; - } - if (value != null && !(value.equals(o.value))) { - return false; - } - return true; + ObjectReference other = (ObjectReference) obj; + return Objects.equals(id, other.id) + && Objects.equals(company, other.company) + && Objects.equals(system, other.system) + && Objects.equals(systemInstance, other.systemInstance) + && Objects.equals(type, other.type) + && Objects.equals(value, other.value); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/TimeInterval.java b/lib/taskana-core/src/main/java/pro/taskana/TimeInterval.java index daf7e0321..7e463bcea 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/TimeInterval.java +++ b/lib/taskana-core/src/main/java/pro/taskana/TimeInterval.java @@ -1,6 +1,7 @@ package pro.taskana; import java.time.Instant; +import java.util.Objects; /** * Capture a time interval. A fixed interval has defined begin and end Instant. An open ended @@ -22,8 +23,8 @@ public class TimeInterval { if (i == null) { return false; } - boolean isAfterBegin = begin == null ? true : !i.isBefore(begin); - boolean isBeforeEnd = end == null ? true : !i.isAfter(end); + boolean isAfterBegin = begin == null || !i.isBefore(begin); + boolean isBeforeEnd = end == null || !i.isAfter(end); return (isAfterBegin && isBeforeEnd); } @@ -53,11 +54,7 @@ public class TimeInterval { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((begin == null) ? 0 : begin.hashCode()); - result = prime * result + ((end == null) ? 0 : end.hashCode()); - return result; + return Objects.hash(begin, end); } @Override @@ -68,25 +65,11 @@ public class TimeInterval { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } TimeInterval other = (TimeInterval) obj; - if (begin == null) { - if (other.begin != null) { - return false; - } - } else if (!begin.equals(other.begin)) { - return false; - } - if (end == null) { - if (other.end != null) { - return false; - } - } else if (!end.equals(other.end)) { - return false; - } - return true; + return Objects.equals(begin, other.begin) && Objects.equals(end, other.end); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentImpl.java index 88ab0f4a8..61b7cd5fc 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentImpl.java @@ -3,6 +3,7 @@ package pro.taskana.impl; import java.time.Instant; import java.util.HashMap; import java.util.Map; +import java.util.Objects; import pro.taskana.Attachment; import pro.taskana.AttachmentSummary; @@ -143,19 +144,16 @@ public class AttachmentImpl implements Attachment { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((channel == null) ? 0 : channel.hashCode()); - result = - prime * result + ((classificationSummary == null) ? 0 : classificationSummary.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((customAttributes == null) ? 0 : customAttributes.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((modified == null) ? 0 : modified.hashCode()); - result = prime * result + ((objectReference == null) ? 0 : objectReference.hashCode()); - result = prime * result + ((received == null) ? 0 : received.hashCode()); - result = prime * result + ((taskId == null) ? 0 : taskId.hashCode()); - return result; + return Objects.hash( + id, + taskId, + created, + modified, + classificationSummary, + objectReference, + channel, + received, + customAttributes); } @Override @@ -166,74 +164,19 @@ public class AttachmentImpl implements Attachment { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } AttachmentImpl other = (AttachmentImpl) obj; - if (channel == null) { - if (other.channel != null) { - return false; - } - } else if (!channel.equals(other.channel)) { - return false; - } - if (classificationSummary == null) { - if (other.classificationSummary != null) { - return false; - } - } else if (!classificationSummary.equals(other.classificationSummary)) { - return false; - } - if (created == null) { - if (other.created != null) { - return false; - } - } else if (!created.equals(other.created)) { - return false; - } - if (customAttributes == null) { - if (other.customAttributes != null) { - return false; - } - } else if (!customAttributes.equals(other.customAttributes)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (modified == null) { - if (other.modified != null) { - return false; - } - } else if (!modified.equals(other.modified)) { - return false; - } - if (objectReference == null) { - if (other.objectReference != null) { - return false; - } - } else if (!objectReference.equals(other.objectReference)) { - return false; - } - if (received == null) { - if (other.received != null) { - return false; - } - } else if (!received.equals(other.received)) { - return false; - } - if (taskId == null) { - if (other.taskId != null) { - return false; - } - } else if (!taskId.equals(other.taskId)) { - return false; - } - return true; + return Objects.equals(id, other.id) + && Objects.equals(taskId, other.taskId) + && Objects.equals(created, other.created) + && Objects.equals(modified, other.modified) + && Objects.equals(classificationSummary, other.classificationSummary) + && Objects.equals(objectReference, other.objectReference) + && Objects.equals(channel, other.channel) + && Objects.equals(received, other.received) + && Objects.equals(customAttributes, other.customAttributes); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentSummaryImpl.java index 256fc1b34..c6f2c4de7 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/AttachmentSummaryImpl.java @@ -1,6 +1,7 @@ package pro.taskana.impl; import java.time.Instant; +import java.util.Objects; import pro.taskana.AttachmentSummary; import pro.taskana.ClassificationSummary; @@ -136,18 +137,8 @@ public class AttachmentSummaryImpl implements AttachmentSummary { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((channel == null) ? 0 : channel.hashCode()); - result = - prime * result + ((classificationSummary == null) ? 0 : classificationSummary.hashCode()); - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((modified == null) ? 0 : modified.hashCode()); - result = prime * result + ((objectReference == null) ? 0 : objectReference.hashCode()); - result = prime * result + ((received == null) ? 0 : received.hashCode()); - result = prime * result + ((taskId == null) ? 0 : taskId.hashCode()); - return result; + return Objects.hash( + id, taskId, created, modified, classificationSummary, objectReference, channel, received); } @Override @@ -158,67 +149,18 @@ public class AttachmentSummaryImpl implements AttachmentSummary { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } AttachmentSummaryImpl other = (AttachmentSummaryImpl) obj; - if (classificationSummary == null) { - if (other.classificationSummary != null) { - return false; - } - } else if (!classificationSummary.equals(other.classificationSummary)) { - return false; - } - if (created == null) { - if (other.created != null) { - return false; - } - } else if (!created.equals(other.created)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (modified == null) { - if (other.modified != null) { - return false; - } - } else if (!modified.equals(other.modified)) { - return false; - } - if (received == null) { - if (other.received != null) { - return false; - } - } else if (!received.equals(other.received)) { - return false; - } - if (taskId == null) { - if (other.taskId != null) { - return false; - } - } else if (!taskId.equals(other.taskId)) { - return false; - } - if (objectReference == null) { - if (other.objectReference != null) { - return false; - } - } else if (!objectReference.equals(other.objectReference)) { - return false; - } - if (channel == null) { - if (other.channel != null) { - return false; - } - } else if (!channel.equals(other.channel)) { - return false; - } - return true; + return Objects.equals(id, other.id) + && Objects.equals(taskId, other.taskId) + && Objects.equals(created, other.created) + && Objects.equals(modified, other.modified) + && Objects.equals(classificationSummary, other.classificationSummary) + && Objects.equals(objectReference, other.objectReference) + && Objects.equals(channel, other.channel) + && Objects.equals(received, other.received); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java index ccb74c5ec..93702b7a1 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationImpl.java @@ -126,32 +126,25 @@ public class ClassificationImpl extends ClassificationSummaryImpl implements Cla } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null) { + if (obj == null) { return false; } - - if (!getClass().isAssignableFrom(o.getClass())) { + if (getClass() != obj.getClass()) { return false; } - - if (!super.equals(o)) { + if (!super.equals(obj)) { return false; } - ClassificationImpl that = (ClassificationImpl) o; - - if (!that.canEqual(this)) { - return false; - } - - return Objects.equals(isValidInDomain, that.isValidInDomain) - && Objects.equals(created, that.created) - && Objects.equals(modified, that.modified) - && Objects.equals(description, that.description) - && Objects.equals(applicationEntryPoint, that.applicationEntryPoint); + ClassificationImpl other = (ClassificationImpl) obj; + return Objects.equals(isValidInDomain, other.isValidInDomain) + && Objects.equals(created, other.created) + && Objects.equals(modified, other.modified) + && Objects.equals(description, other.description) + && Objects.equals(applicationEntryPoint, other.applicationEntryPoint); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java index 80eb4921f..7768f6786 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/ClassificationSummaryImpl.java @@ -218,42 +218,35 @@ public class ClassificationSummaryImpl implements ClassificationSummary { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object obj) { + if (this == obj) { return true; } - if (o == null) { + if (obj == null) { return false; } - - if (!getClass().isAssignableFrom(o.getClass())) { + if (getClass() != obj.getClass()) { return false; } - - ClassificationSummaryImpl that = (ClassificationSummaryImpl) o; - - if (!that.canEqual(this)) { - return false; - } - - return priority == that.priority - && Objects.equals(id, that.id) - && Objects.equals(key, that.key) - && Objects.equals(category, that.category) - && Objects.equals(type, that.type) - && Objects.equals(domain, that.domain) - && Objects.equals(name, that.name) - && Objects.equals(parentId, that.parentId) - && Objects.equals(parentKey, that.parentKey) - && Objects.equals(serviceLevel, that.serviceLevel) - && Objects.equals(custom1, that.custom1) - && Objects.equals(custom2, that.custom2) - && Objects.equals(custom3, that.custom3) - && Objects.equals(custom4, that.custom4) - && Objects.equals(custom5, that.custom5) - && Objects.equals(custom6, that.custom6) - && Objects.equals(custom7, that.custom7) - && Objects.equals(custom8, that.custom8); + ClassificationSummaryImpl other = (ClassificationSummaryImpl) obj; + return priority == other.priority + && Objects.equals(id, other.id) + && Objects.equals(key, other.key) + && Objects.equals(category, other.category) + && Objects.equals(type, other.type) + && Objects.equals(domain, other.domain) + && Objects.equals(name, other.name) + && Objects.equals(parentId, other.parentId) + && Objects.equals(parentKey, other.parentKey) + && Objects.equals(serviceLevel, other.serviceLevel) + && Objects.equals(custom1, other.custom1) + && Objects.equals(custom2, other.custom2) + && Objects.equals(custom3, other.custom3) + && Objects.equals(custom4, other.custom4) + && Objects.equals(custom5, other.custom5) + && Objects.equals(custom6, other.custom6) + && Objects.equals(custom7, other.custom7) + && Objects.equals(custom8, other.custom8); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java index e891458e4..7ca1994f0 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskImpl.java @@ -7,6 +7,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; +import java.util.Objects; import pro.taskana.Attachment; import pro.taskana.AttachmentSummary; @@ -18,7 +19,6 @@ import pro.taskana.TaskState; import pro.taskana.TaskSummary; import pro.taskana.WorkbasketSummary; import pro.taskana.exceptions.InvalidArgumentException; -import pro.taskana.exceptions.SystemException; /** Task entity. */ public class TaskImpl implements Task { @@ -722,57 +722,49 @@ public class TaskImpl implements Task { @Override public int hashCode() { - final int prime = 31; - int result = 1; - Object[] myFields = { - externalId, - attachments, - businessProcessId, - claimed, - classificationSummary, - completed, - created, - creator, - custom1, - custom10, - custom11, - custom12, - custom13, - custom14, - custom15, - custom16, - custom2, - custom3, - custom4, - custom5, - custom6, - custom7, - custom8, - custom9, - customAttributes, - callbackInfo, - callbackState, - description, - due, - id, - modified, - name, - note, - owner, - parentBusinessProcessId, - planned, - primaryObjRef, - state, - workbasketSummary - }; - - for (Object property : myFields) { - result = prime * result + (property == null ? 0 : property.hashCode()); - } - result = prime * result + (isRead ? 1231 : 1237); - result = prime * result + (isTransferred ? 1231 : 1237); - result = prime * result + priority; - return result; + return Objects.hash( + id, + externalId, + created, + claimed, + completed, + modified, + planned, + due, + name, + creator, + description, + note, + priority, + state, + classificationSummary, + workbasketSummary, + businessProcessId, + parentBusinessProcessId, + owner, + primaryObjRef, + isRead, + isTransferred, + customAttributes, + callbackInfo, + callbackState, + attachments, + custom1, + custom2, + custom3, + custom4, + custom5, + custom6, + custom7, + custom8, + custom9, + custom10, + custom11, + custom12, + custom13, + custom14, + custom15, + custom16); } @Override @@ -783,112 +775,52 @@ public class TaskImpl implements Task { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } TaskImpl other = (TaskImpl) obj; - - Object[] myFields = { - externalId, - attachments, - businessProcessId, - claimed, - classificationSummary, - completed, - created, - creator, - custom1, - custom10, - custom11, - custom12, - custom13, - custom14, - custom15, - custom16, - custom2, - custom3, - custom4, - custom5, - custom6, - custom7, - custom8, - custom9, - customAttributes, - callbackInfo, - callbackState, - description, - due, - id, - modified, - name, - note, - owner, - parentBusinessProcessId, - planned, - primaryObjRef, - state, - workbasketSummary - }; - - Object[] otherFields = { - other.externalId, - other.attachments, - other.businessProcessId, - other.claimed, - other.classificationSummary, - other.completed, - other.created, - other.creator, - other.custom1, - other.custom10, - other.custom11, - other.custom12, - other.custom13, - other.custom14, - other.custom15, - other.custom16, - other.custom2, - other.custom3, - other.custom4, - other.custom5, - other.custom6, - other.custom7, - other.custom8, - other.custom9, - other.customAttributes, - other.callbackInfo, - other.callbackState, - other.description, - other.due, - other.id, - other.modified, - other.name, - other.note, - other.owner, - other.parentBusinessProcessId, - other.planned, - other.primaryObjRef, - other.state, - other.workbasketSummary - }; - - if (myFields.length != otherFields.length) { - throw new SystemException("TaskSummaryImpl: length mismatch between internal arrays"); - } - for (int i = 0; i < myFields.length; i++) { - if ((myFields[i] == null && otherFields[i] != null) - || (myFields[i] != null && !myFields[i].equals(otherFields[i]))) { - return false; - } - } - if (isRead != other.isRead) { - return false; - } - if (isTransferred != other.isTransferred) { - return false; - } - - return (priority == other.priority); + return priority == other.priority + && isRead == other.isRead + && isTransferred == other.isTransferred + && Objects.equals(id, other.id) + && Objects.equals(externalId, other.externalId) + && Objects.equals(created, other.created) + && Objects.equals(claimed, other.claimed) + && Objects.equals(completed, other.completed) + && Objects.equals(modified, other.modified) + && Objects.equals(planned, other.planned) + && Objects.equals(due, other.due) + && Objects.equals(name, other.name) + && Objects.equals(creator, other.creator) + && Objects.equals(description, other.description) + && Objects.equals(note, other.note) + && state == other.state + && Objects.equals(classificationSummary, other.classificationSummary) + && Objects.equals(workbasketSummary, other.workbasketSummary) + && Objects.equals(businessProcessId, other.businessProcessId) + && Objects.equals(parentBusinessProcessId, other.parentBusinessProcessId) + && Objects.equals(owner, other.owner) + && Objects.equals(primaryObjRef, other.primaryObjRef) + && Objects.equals(customAttributes, other.customAttributes) + && Objects.equals(callbackInfo, other.callbackInfo) + && callbackState == other.callbackState + && Objects.equals(attachments, other.attachments) + && Objects.equals(custom1, other.custom1) + && Objects.equals(custom2, other.custom2) + && Objects.equals(custom3, other.custom3) + && Objects.equals(custom4, other.custom4) + && Objects.equals(custom5, other.custom5) + && Objects.equals(custom6, other.custom6) + && Objects.equals(custom7, other.custom7) + && Objects.equals(custom8, other.custom8) + && Objects.equals(custom9, other.custom9) + && Objects.equals(custom10, other.custom10) + && Objects.equals(custom11, other.custom11) + && Objects.equals(custom12, other.custom12) + && Objects.equals(custom13, other.custom13) + && Objects.equals(custom14, other.custom14) + && Objects.equals(custom15, other.custom15) + && Objects.equals(custom16, other.custom16); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java index de8d23ae3..b9c1df53f 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/TaskSummaryImpl.java @@ -3,6 +3,7 @@ package pro.taskana.impl; import java.time.Instant; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import pro.taskana.AttachmentSummary; import pro.taskana.ClassificationSummary; @@ -11,7 +12,6 @@ import pro.taskana.TaskState; import pro.taskana.TaskSummary; import pro.taskana.WorkbasketSummary; import pro.taskana.exceptions.InvalidArgumentException; -import pro.taskana.exceptions.SystemException; /** Entity which contains the most important informations about a Task. */ public class TaskSummaryImpl implements TaskSummary { @@ -590,53 +590,45 @@ public class TaskSummaryImpl implements TaskSummary { @Override public int hashCode() { - final int prime = 31; - int result = 1; - Object[] myFields = { - externalId, - attachmentSummaries, - businessProcessId, - claimed, - classificationSummary, - completed, - created, - creator, - custom1, - custom10, - custom11, - custom12, - custom13, - custom14, - custom15, - custom16, - custom2, - custom3, - custom4, - custom5, - custom6, - custom7, - custom8, - custom9, - due, - modified, - name, - note, - owner, - parentBusinessProcessId, - planned, - primaryObjRef, - state, - taskId, - workbasketSummary - }; - - for (Object property : myFields) { - result = prime * result + (property == null ? 0 : property.hashCode()); - } - result = prime * result + (isRead ? 1231 : 1237); - result = prime * result + (isTransferred ? 1231 : 1237); - result = prime * result + priority; - return result; + return Objects.hash( + taskId, + externalId, + created, + claimed, + completed, + modified, + planned, + due, + name, + creator, + note, + priority, + state, + classificationSummary, + workbasketSummary, + businessProcessId, + parentBusinessProcessId, + owner, + primaryObjRef, + isRead, + isTransferred, + attachmentSummaries, + custom1, + custom2, + custom3, + custom4, + custom5, + custom6, + custom7, + custom8, + custom9, + custom10, + custom11, + custom12, + custom13, + custom14, + custom15, + custom16); } @Override @@ -647,103 +639,48 @@ public class TaskSummaryImpl implements TaskSummary { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } TaskSummaryImpl other = (TaskSummaryImpl) obj; - Object[] myFields = { - externalId, - attachmentSummaries, - businessProcessId, - claimed, - classificationSummary, - completed, - created, - creator, - custom1, - custom10, - custom11, - custom12, - custom13, - custom14, - custom15, - custom16, - custom2, - custom3, - custom4, - custom5, - custom6, - custom7, - custom8, - custom9, - due, - modified, - name, - note, - owner, - parentBusinessProcessId, - planned, - primaryObjRef, - state, - taskId, - workbasketSummary - }; - - Object[] otherFields = { - other.externalId, - other.attachmentSummaries, - other.businessProcessId, - other.claimed, - other.classificationSummary, - other.completed, - other.created, - other.creator, - other.custom1, - other.custom10, - other.custom11, - other.custom12, - other.custom13, - other.custom14, - other.custom15, - other.custom16, - other.custom2, - other.custom3, - other.custom4, - other.custom5, - other.custom6, - other.custom7, - other.custom8, - other.custom9, - other.due, - other.modified, - other.name, - other.note, - other.owner, - other.parentBusinessProcessId, - other.planned, - other.primaryObjRef, - other.state, - other.taskId, - other.workbasketSummary - }; - - if (myFields.length != otherFields.length) { - throw new SystemException("TaskSummaryImpl: length mismatch between internal arrays"); - } - for (int i = 0; i < myFields.length; i++) { - if ((myFields[i] == null && otherFields[i] != null) - || (myFields[i] != null && !myFields[i].equals(otherFields[i]))) { - return false; - } - } - if (isRead != other.isRead) { - return false; - } - if (isTransferred != other.isTransferred) { - return false; - } - - return (priority == other.priority); + return priority == other.priority + && isRead == other.isRead + && isTransferred == other.isTransferred + && Objects.equals(taskId, other.taskId) + && Objects.equals(externalId, other.externalId) + && Objects.equals(created, other.created) + && Objects.equals(claimed, other.claimed) + && Objects.equals(completed, other.completed) + && Objects.equals(modified, other.modified) + && Objects.equals(planned, other.planned) + && Objects.equals(due, other.due) + && Objects.equals(name, other.name) + && Objects.equals(creator, other.creator) + && Objects.equals(note, other.note) + && state == other.state + && Objects.equals(classificationSummary, other.classificationSummary) + && Objects.equals(workbasketSummary, other.workbasketSummary) + && Objects.equals(businessProcessId, other.businessProcessId) + && Objects.equals(parentBusinessProcessId, other.parentBusinessProcessId) + && Objects.equals(owner, other.owner) + && Objects.equals(primaryObjRef, other.primaryObjRef) + && Objects.equals(attachmentSummaries, other.attachmentSummaries) + && Objects.equals(custom1, other.custom1) + && Objects.equals(custom2, other.custom2) + && Objects.equals(custom3, other.custom3) + && Objects.equals(custom4, other.custom4) + && Objects.equals(custom5, other.custom5) + && Objects.equals(custom6, other.custom6) + && Objects.equals(custom7, other.custom7) + && Objects.equals(custom8, other.custom8) + && Objects.equals(custom9, other.custom9) + && Objects.equals(custom10, other.custom10) + && Objects.equals(custom11, other.custom11) + && Objects.equals(custom12, other.custom12) + && Objects.equals(custom13, other.custom13) + && Objects.equals(custom14, other.custom14) + && Objects.equals(custom15, other.custom15) + && Objects.equals(custom16, other.custom16); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java index ddf9f9d98..125ddac4b 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketAccessItemImpl.java @@ -1,5 +1,7 @@ package pro.taskana.impl; +import java.util.Objects; + import pro.taskana.WorkbasketAccessItem; import pro.taskana.configuration.TaskanaEngineConfiguration; @@ -415,31 +417,29 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((accessId == null) ? 0 : accessId.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + (permAppend ? 1231 : 1237); - result = prime * result + (permCustom1 ? 1231 : 1237); - result = prime * result + (permCustom10 ? 1231 : 1237); - result = prime * result + (permCustom11 ? 1231 : 1237); - result = prime * result + (permCustom12 ? 1231 : 1237); - result = prime * result + (permCustom2 ? 1231 : 1237); - result = prime * result + (permCustom3 ? 1231 : 1237); - result = prime * result + (permCustom4 ? 1231 : 1237); - result = prime * result + (permCustom5 ? 1231 : 1237); - result = prime * result + (permCustom6 ? 1231 : 1237); - result = prime * result + (permCustom7 ? 1231 : 1237); - result = prime * result + (permCustom8 ? 1231 : 1237); - result = prime * result + (permCustom9 ? 1231 : 1237); - result = prime * result + (permDistribute ? 1231 : 1237); - result = prime * result + (permOpen ? 1231 : 1237); - result = prime * result + (permRead ? 1231 : 1237); - result = prime * result + (permTransfer ? 1231 : 1237); - result = prime * result + ((workbasketId == null) ? 0 : workbasketId.hashCode()); - result = prime * result + ((workbasketKey == null) ? 0 : workbasketKey.hashCode()); - result = prime * result + ((accessName == null) ? 0 : accessName.hashCode()); - return result; + return Objects.hash( + id, + workbasketId, + workbasketKey, + accessId, + accessName, + permRead, + permOpen, + permAppend, + permTransfer, + permDistribute, + permCustom1, + permCustom2, + permCustom3, + permCustom4, + permCustom5, + permCustom6, + permCustom7, + permCustom8, + permCustom9, + permCustom10, + permCustom11, + permCustom12); } @Override @@ -450,97 +450,32 @@ public class WorkbasketAccessItemImpl implements WorkbasketAccessItem { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } WorkbasketAccessItemImpl other = (WorkbasketAccessItemImpl) obj; - if (accessId == null) { - if (other.accessId != null) { - return false; - } - } else if (!accessId.equals(other.accessId)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (permAppend != other.permAppend) { - return false; - } - if (permCustom1 != other.permCustom1) { - return false; - } - if (permCustom10 != other.permCustom10) { - return false; - } - if (permCustom11 != other.permCustom11) { - return false; - } - if (permCustom12 != other.permCustom12) { - return false; - } - if (permCustom2 != other.permCustom2) { - return false; - } - if (permCustom3 != other.permCustom3) { - return false; - } - if (permCustom4 != other.permCustom4) { - return false; - } - if (permCustom5 != other.permCustom5) { - return false; - } - if (permCustom6 != other.permCustom6) { - return false; - } - if (permCustom7 != other.permCustom7) { - return false; - } - if (permCustom8 != other.permCustom8) { - return false; - } - if (permCustom9 != other.permCustom9) { - return false; - } - if (permDistribute != other.permDistribute) { - return false; - } - if (permOpen != other.permOpen) { - return false; - } - if (permRead != other.permRead) { - return false; - } - if (permTransfer != other.permTransfer) { - return false; - } - if (workbasketId == null) { - if (other.workbasketId != null) { - return false; - } - } else if (!workbasketId.equals(other.workbasketId)) { - return false; - } - if (workbasketKey == null) { - if (other.workbasketKey != null) { - return false; - } - } else if (!workbasketKey.equals(other.workbasketKey)) { - return false; - } - if (accessName == null) { - if (other.accessName != null) { - return false; - } - } else if (!accessName.equals(other.accessName)) { - return false; - } - return true; + return permRead == other.permRead + && permOpen == other.permOpen + && permAppend == other.permAppend + && permTransfer == other.permTransfer + && permDistribute == other.permDistribute + && permCustom1 == other.permCustom1 + && permCustom2 == other.permCustom2 + && permCustom3 == other.permCustom3 + && permCustom4 == other.permCustom4 + && permCustom5 == other.permCustom5 + && permCustom6 == other.permCustom6 + && permCustom7 == other.permCustom7 + && permCustom8 == other.permCustom8 + && permCustom9 == other.permCustom9 + && permCustom10 == other.permCustom10 + && permCustom11 == other.permCustom11 + && permCustom12 == other.permCustom12 + && Objects.equals(id, other.id) + && Objects.equals(workbasketId, other.workbasketId) + && Objects.equals(workbasketKey, other.workbasketKey) + && Objects.equals(accessId, other.accessId) + && Objects.equals(accessName, other.accessName); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java index ba521e6ad..f914fddfa 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketImpl.java @@ -1,6 +1,7 @@ package pro.taskana.impl; import java.time.Instant; +import java.util.Objects; import pro.taskana.Workbasket; import pro.taskana.WorkbasketSummary; @@ -229,27 +230,25 @@ public class WorkbasketImpl implements Workbasket { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((created == null) ? 0 : created.hashCode()); - result = prime * result + ((custom1 == null) ? 0 : custom1.hashCode()); - result = prime * result + ((custom2 == null) ? 0 : custom2.hashCode()); - result = prime * result + ((custom3 == null) ? 0 : custom3.hashCode()); - result = prime * result + ((custom4 == null) ? 0 : custom4.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + (markedForDeletion ? 1231 : 1237); - result = prime * result + ((modified == null) ? 0 : modified.hashCode()); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((orgLevel1 == null) ? 0 : orgLevel1.hashCode()); - result = prime * result + ((orgLevel2 == null) ? 0 : orgLevel2.hashCode()); - result = prime * result + ((orgLevel3 == null) ? 0 : orgLevel3.hashCode()); - result = prime * result + ((orgLevel4 == null) ? 0 : orgLevel4.hashCode()); - result = prime * result + ((owner == null) ? 0 : owner.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; + return Objects.hash( + id, + key, + created, + modified, + name, + description, + owner, + domain, + type, + custom1, + custom2, + custom3, + custom4, + orgLevel1, + orgLevel2, + orgLevel3, + orgLevel4, + markedForDeletion); } @Override @@ -260,130 +259,28 @@ public class WorkbasketImpl implements Workbasket { if (obj == null) { return false; } - - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } WorkbasketImpl other = (WorkbasketImpl) obj; - if (created == null) { - if (other.created != null) { - return false; - } - } else if (!created.equals(other.created)) { - return false; - } - if (custom1 == null) { - if (other.custom1 != null) { - return false; - } - } else if (!custom1.equals(other.custom1)) { - return false; - } - if (custom2 == null) { - if (other.custom2 != null) { - return false; - } - } else if (!custom2.equals(other.custom2)) { - return false; - } - if (custom3 == null) { - if (other.custom3 != null) { - return false; - } - } else if (!custom3.equals(other.custom3)) { - return false; - } - if (custom4 == null) { - if (other.custom4 != null) { - return false; - } - } else if (!custom4.equals(other.custom4)) { - return false; - } - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (domain == null) { - if (other.domain != null) { - return false; - } - } else if (!domain.equals(other.domain)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equals(other.key)) { - return false; - } - if (markedForDeletion != other.markedForDeletion) { - return false; - } - if (modified == null) { - if (other.modified != null) { - return false; - } - } else if (!modified.equals(other.modified)) { - return false; - } - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (orgLevel1 == null) { - if (other.orgLevel1 != null) { - return false; - } - } else if (!orgLevel1.equals(other.orgLevel1)) { - return false; - } - if (orgLevel2 == null) { - if (other.orgLevel2 != null) { - return false; - } - } else if (!orgLevel2.equals(other.orgLevel2)) { - return false; - } - if (orgLevel3 == null) { - if (other.orgLevel3 != null) { - return false; - } - } else if (!orgLevel3.equals(other.orgLevel3)) { - return false; - } - if (orgLevel4 == null) { - if (other.orgLevel4 != null) { - return false; - } - } else if (!orgLevel4.equals(other.orgLevel4)) { - return false; - } - if (owner == null) { - if (other.owner != null) { - return false; - } - } else if (!owner.equals(other.owner)) { - return false; - } - if (type != other.type) { - return false; - } - return true; + return markedForDeletion == other.markedForDeletion + && Objects.equals(id, other.id) + && Objects.equals(key, other.key) + && Objects.equals(created, other.created) + && Objects.equals(modified, other.modified) + && Objects.equals(name, other.name) + && Objects.equals(description, other.description) + && Objects.equals(owner, other.owner) + && Objects.equals(domain, other.domain) + && type == other.type + && Objects.equals(custom1, other.custom1) + && Objects.equals(custom2, other.custom2) + && Objects.equals(custom3, other.custom3) + && Objects.equals(custom4, other.custom4) + && Objects.equals(orgLevel1, other.orgLevel1) + && Objects.equals(orgLevel2, other.orgLevel2) + && Objects.equals(orgLevel3, other.orgLevel3) + && Objects.equals(orgLevel4, other.orgLevel4); } @Override diff --git a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java index 9e4aa1ec0..a0dfe72f1 100644 --- a/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java +++ b/lib/taskana-core/src/main/java/pro/taskana/impl/WorkbasketSummaryImpl.java @@ -1,5 +1,7 @@ package pro.taskana.impl; +import java.util.Objects; + import pro.taskana.WorkbasketSummary; import pro.taskana.WorkbasketType; @@ -231,25 +233,23 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { @Override public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((custom1 == null) ? 0 : custom1.hashCode()); - result = prime * result + ((custom2 == null) ? 0 : custom2.hashCode()); - result = prime * result + ((custom3 == null) ? 0 : custom3.hashCode()); - result = prime * result + ((custom4 == null) ? 0 : custom4.hashCode()); - result = prime * result + ((description == null) ? 0 : description.hashCode()); - result = prime * result + ((domain == null) ? 0 : domain.hashCode()); - result = prime * result + ((id == null) ? 0 : id.hashCode()); - result = prime * result + ((key == null) ? 0 : key.hashCode()); - result = prime * result + (markedForDeletion ? 1231 : 1237); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - result = prime * result + ((orgLevel1 == null) ? 0 : orgLevel1.hashCode()); - result = prime * result + ((orgLevel2 == null) ? 0 : orgLevel2.hashCode()); - result = prime * result + ((orgLevel3 == null) ? 0 : orgLevel3.hashCode()); - result = prime * result + ((orgLevel4 == null) ? 0 : orgLevel4.hashCode()); - result = prime * result + ((owner == null) ? 0 : owner.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - return result; + return Objects.hash( + id, + key, + name, + description, + owner, + domain, + type, + custom1, + custom2, + custom3, + custom4, + orgLevel1, + orgLevel2, + orgLevel3, + orgLevel4, + markedForDeletion); } @Override @@ -260,115 +260,26 @@ public class WorkbasketSummaryImpl implements WorkbasketSummary { if (obj == null) { return false; } - if (!getClass().isAssignableFrom(obj.getClass())) { + if (getClass() != obj.getClass()) { return false; } WorkbasketSummaryImpl other = (WorkbasketSummaryImpl) obj; - if (custom1 == null) { - if (other.custom1 != null) { - return false; - } - } else if (!custom1.equals(other.custom1)) { - return false; - } - if (custom2 == null) { - if (other.custom2 != null) { - return false; - } - } else if (!custom2.equals(other.custom2)) { - return false; - } - if (custom3 == null) { - if (other.custom3 != null) { - return false; - } - } else if (!custom3.equals(other.custom3)) { - return false; - } - if (custom4 == null) { - if (other.custom4 != null) { - return false; - } - } else if (!custom4.equals(other.custom4)) { - return false; - } - if (description == null) { - if (other.description != null) { - return false; - } - } else if (!description.equals(other.description)) { - return false; - } - if (domain == null) { - if (other.domain != null) { - return false; - } - } else if (!domain.equals(other.domain)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (key == null) { - if (other.key != null) { - return false; - } - } else if (!key.equals(other.key)) { - return false; - } - if (markedForDeletion != other.markedForDeletion) { - return false; - } - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (orgLevel1 == null) { - if (other.orgLevel1 != null) { - return false; - } - } else if (!orgLevel1.equals(other.orgLevel1)) { - return false; - } - if (orgLevel2 == null) { - if (other.orgLevel2 != null) { - return false; - } - } else if (!orgLevel2.equals(other.orgLevel2)) { - return false; - } - if (orgLevel3 == null) { - if (other.orgLevel3 != null) { - return false; - } - } else if (!orgLevel3.equals(other.orgLevel3)) { - return false; - } - if (orgLevel4 == null) { - if (other.orgLevel4 != null) { - return false; - } - } else if (!orgLevel4.equals(other.orgLevel4)) { - return false; - } - if (owner == null) { - if (other.owner != null) { - return false; - } - } else if (!owner.equals(other.owner)) { - return false; - } - if (type != other.type) { - return false; - } - return true; + return markedForDeletion == other.markedForDeletion + && Objects.equals(id, other.id) + && Objects.equals(key, other.key) + && Objects.equals(name, other.name) + && Objects.equals(description, other.description) + && Objects.equals(owner, other.owner) + && Objects.equals(domain, other.domain) + && type == other.type + && Objects.equals(custom1, other.custom1) + && Objects.equals(custom2, other.custom2) + && Objects.equals(custom3, other.custom3) + && Objects.equals(custom4, other.custom4) + && Objects.equals(orgLevel1, other.orgLevel1) + && Objects.equals(orgLevel2, other.orgLevel2) + && Objects.equals(orgLevel3, other.orgLevel3) + && Objects.equals(orgLevel4, other.orgLevel4); } @Override