Greg Padgett has uploaded a new change for review. Change subject: core: simplify businessentity equals() methods [part 1] ......................................................................
core: simplify businessentity equals() methods [part 1] Instead of manually doing a null-safe comparison for each business entity, use ObjectUtils.objectsEqual(). Where applicable, optimize the order of comparison by looking at the id field first. The resulting code is more concise, easier to maintain, and doesn't mask errors due to missing braces like the previous code did. Change-Id: Ie9531a453a352619e8a6243ea1a5e4d0de4d1a45 Signed-off-by: Greg Padgett <gpadg...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionVersionMap.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AsyncTasks.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Bookmark.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitySnapshot.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DbUser.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Disk.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImageDynamic.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMap.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMapId.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Image.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStorageDomainMapId.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_notification_hist.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber_id.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_storage_domain_map.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map_id.java 20 files changed, 227 insertions(+), 596 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/12342/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionVersionMap.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionVersionMap.java index 757ed79..bfc67d9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionVersionMap.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ActionVersionMap.java @@ -3,6 +3,7 @@ import java.io.Serializable; import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Version; public class ActionVersionMap implements Serializable { @@ -83,25 +84,18 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ActionVersionMap other = (ActionVersionMap) obj; - if (actionType != other.actionType) - return false; - if (clusterMinimalVersion == null) { - if (other.clusterMinimalVersion != null) - return false; - } else if (!clusterMinimalVersion.equals(other.clusterMinimalVersion)) - return false; - if (storagePoolMinimalVersion == null) { - if (other.storagePoolMinimalVersion != null) - return false; - } else if (!storagePoolMinimalVersion.equals(other.storagePoolMinimalVersion)) - return false; - return true; + return (actionType == other.actionType + && ObjectUtils.objectsEqual(clusterMinimalVersion, other.clusterMinimalVersion) + && ObjectUtils.objectsEqual(storagePoolMinimalVersion, other.storagePoolMinimalVersion)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AsyncTasks.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AsyncTasks.java index 9b7e478..7f8d854 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AsyncTasks.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AsyncTasks.java @@ -6,6 +6,7 @@ import org.ovirt.engine.core.common.action.VdcActionParametersBase; import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.asynctasks.AsyncTaskType; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.NGuid; @@ -164,65 +165,25 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } AsyncTasks other = (AsyncTasks) obj; - if (actionParameters == null) { - if (other.actionParameters != null) - return false; - } else if (!actionParameters.equals(other.actionParameters)) - return false; - if (actionType != other.actionType) - return false; - if (result != other.result) - return false; - if (status != other.status) - return false; - if (taskId == null) { - if (other.taskId != null) - return false; - } else if (!taskId.equals(other.taskId)) - return false; - if (stepId == null) { - if (other.stepId != null) { - return false; - } - } else if (!stepId.equals(other.stepId)) { - return false; - } - if (commandId == null) { - if (other.commandId != null) { - return false; - } - } else if (!commandId.equals(other.commandId)) { - return false; - } - if (startTime == null) { - if (other.startTime != null) { - return false; - } - } else if (!startTime.equals(other.startTime)) { - return false; - } - if (storagePoolId == null) { - if (other.storagePoolId != null) { - return false; - } - } else if (!storagePoolId.equals(other.storagePoolId)) { - return false; - } - if (taskType == null) { - if (other.taskType != null) { - return false; - } - } else if (!taskType.equals(other.taskType)) { - return false; - } - - return true; + return (ObjectUtils.objectsEqual(taskId, other.taskId) + && ObjectUtils.objectsEqual(stepId, other.stepId) + && ObjectUtils.objectsEqual(commandId, other.commandId) + && ObjectUtils.objectsEqual(actionParameters, other.actionParameters) + && actionType == other.actionType + && result == other.result + && status == other.status + && ObjectUtils.objectsEqual(startTime, other.startTime) + && ObjectUtils.objectsEqual(storagePoolId, other.storagePoolId) + && ObjectUtils.objectsEqual(taskType, other.taskType)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java index bece962..feacc02 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/AuditLog.java @@ -5,6 +5,7 @@ import org.ovirt.engine.core.common.AuditLogSeverity; import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.NGuid; public class AuditLog extends IVdcQueryable implements Serializable { @@ -406,94 +407,36 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } AuditLog other = (AuditLog) obj; - if (auditLogId != other.auditLogId) - return false; - if (logTime == null) { - if (other.logTime != null) - return false; - } else if (!logTime.equals(other.logTime)) - return false; - if (logType != other.logType) - return false; - if (message == null) { - if (other.message != null) - return false; - } else if (!message.equals(other.message)) - return false; - if (storageDomainId == null) { - if (other.storageDomainId != null) - return false; - } else if (!storageDomainId.equals(other.storageDomainId)) - return false; - if (storagePoolId == null) { - if (other.storagePoolId != null) - return false; - } else if (!storagePoolId.equals(other.storagePoolId)) - return false; - if (severity != other.severity) - return false; - if (userId == null) { - if (other.userId != null) - return false; - } else if (!userId.equals(other.userId)) - return false; - if (vdsId == null) { - if (other.vdsId != null) - return false; - } else if (!vdsId.equals(other.vdsId)) - return false; - if (quotaId == null) { - if (other.quotaId != null) - return false; - } else if (!quotaId.equals(other.quotaId)) - return false; - if (vmId == null) { - if (other.vmId != null) - return false; - } else if (!vmId.equals(other.vmId)) - return false; - if (vmTemplateId == null) { - if (other.vmTemplateId != null) - return false; - } else if (!vmTemplateId.equals(other.vmTemplateId)) - return false; - if(processed != other.processed) - return false; - if (correlationId == null) { - if (other.correlationId != null) - return false; - } else if (!correlationId.equals(other.correlationId)) - return false; - if (jobId == null) { - if (other.jobId != null) - return false; - } else if (!jobId.equals(other.jobId)) - return false; - if (origin == null) { - if (other.origin != null) - return false; - } else if (!origin.equals(other.origin)) - return false; - if (customEventId != other.customEventId) - return false; - if (eventFloodInSec != other.eventFloodInSec) - return false; - if (customData == null) { - if (other.customData != null) - return false; - } else if (!customData.equals(other.customData)) - return false; - if (external != other.external) - return false; - if (deleted != other.deleted) - return false; - return true; + return (auditLogId == other.auditLogId + && ObjectUtils.objectsEqual(logTime, other.logTime) + && logType == other.logType + && ObjectUtils.objectsEqual(message, other.message) + && ObjectUtils.objectsEqual(storageDomainId, other.storageDomainId) + && ObjectUtils.objectsEqual(storagePoolId, other.storagePoolId) + && severity == other.severity + && ObjectUtils.objectsEqual(userId, other.userId) + && ObjectUtils.objectsEqual(vdsId, other.vdsId) + && ObjectUtils.objectsEqual(quotaId, other.quotaId) + && ObjectUtils.objectsEqual(vmId, other.vmId) + && ObjectUtils.objectsEqual(vmTemplateId, other.vmTemplateId) + && processed == other.processed + && ObjectUtils.objectsEqual(correlationId, other.correlationId) + && ObjectUtils.objectsEqual(jobId, other.jobId) + && ObjectUtils.objectsEqual(origin, other.origin) + && customEventId == other.customEventId + && eventFloodInSec == other.eventFloodInSec + && ObjectUtils.objectsEqual(customData, other.customData) + && external == other.external + && deleted == other.deleted); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java index d5fb227..3d79ca9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BaseDisk.java @@ -3,6 +3,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.validation.annotation.ValidDescription; import org.ovirt.engine.core.common.validation.annotation.ValidI18NName; import org.ovirt.engine.core.common.validation.group.CreateEntity; @@ -188,38 +189,23 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } BaseDisk other = (BaseDisk) obj; - if (diskAlias == null) { - if (other.diskAlias != null) - return false; - } else if (!diskAlias.equals(other.diskAlias)) - return false; - if (diskDescription == null) { - if (other.diskDescription != null) - return false; - } else if (!diskDescription.equals(other.diskDescription)) - return false; - if (diskInterface != other.diskInterface) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (propagateErrors != other.propagateErrors) - return false; - if (shareable != other.shareable) - return false; - if (isWipeAfterDelete() != other.isWipeAfterDelete()) - return false; - if (boot != other.boot) - return false; - return true; + return (ObjectUtils.objectsEqual(id, other.id) + && ObjectUtils.objectsEqual(diskAlias, other.diskAlias) + && ObjectUtils.objectsEqual(diskDescription, other.diskDescription) + && diskInterface == other.diskInterface + && propagateErrors == other.propagateErrors + && shareable == other.shareable + && isWipeAfterDelete() == other.isWipeAfterDelete() + && boot == other.boot); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Bookmark.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Bookmark.java index 26fa431..c3ebdcd 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Bookmark.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Bookmark.java @@ -4,6 +4,7 @@ import javax.validation.constraints.Size; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class Bookmark extends IVdcQueryable implements Serializable { @@ -62,16 +63,19 @@ @Override public boolean equals(Object obj) { - if (obj == null) + if (this == obj) { + return true; + } + if (obj == null) { return false; - if (obj.getClass() != this.getClass()) + } + if (obj.getClass() != this.getClass()) { return false; - Bookmark that = (Bookmark) obj; - boolean result = this.id.equals(that.id); - result &= this.name.equals(that.name); - result &= this.value.equals(that.value); - - return result; + } + Bookmark other = (Bookmark) obj; + return (ObjectUtils.objectsEqual(id, other.id) + && ObjectUtils.objectsEqual(name, other.name) + && ObjectUtils.objectsEqual(value, other.value)); } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitySnapshot.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitySnapshot.java index 3c381de..5bd9ffd 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitySnapshot.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/BusinessEntitySnapshot.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; /** @@ -134,24 +135,18 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } BusinessEntitySnapshot other = (BusinessEntitySnapshot) obj; - if (commandId == null) { - if (other.commandId != null) - return false; - } else if (!commandId.equals(other.commandId)) - return false; - if (entityId == null) { - if (other.entityId != null) - return false; - } else if (!entityId.equals(other.entityId)) - return false; - return true; + return (ObjectUtils.objectsEqual(commandId, other.commandId) + && ObjectUtils.objectsEqual(entityId, other.entityId)); } /** diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DbUser.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DbUser.java index 9711e21..025f773 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DbUser.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DbUser.java @@ -2,6 +2,7 @@ import javax.validation.constraints.Size; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringHelper; @@ -118,78 +119,30 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } DbUser other = (DbUser) obj; - if (department == null) { - if (other.department != null) - return false; - } else if (!department.equals(other.department)) - return false; - if (desktopDevice == null) { - if (other.desktopDevice != null) - return false; - } else if (!desktopDevice.equals(other.desktopDevice)) - return false; - if (domain == null) { - if (other.domain != null) - return false; - } else if (!domain.equals(other.domain)) - return false; - if (email == null) { - if (other.email != null) - return false; - } else if (!email.equals(other.email)) - return false; - if (groups == null) { - if (other.groups != null) - return false; - } else if (!groups.equals(other.groups)) - return false; - if (lastAdminCheckStatus != other.lastAdminCheckStatus) - return false; - if (name == null) { - if (other.name != null) - return false; - } else if (!name.equals(other.name)) - return false; - if (note == null) { - if (other.note != null) - return false; - } else if (!note.equals(other.note)) - return false; - if (role == null) { - if (other.role != null) - return false; - } else if (!role.equals(other.role)) - return false; - if (status != other.status) - return false; - if (surname == null) { - if (other.surname != null) - return false; - } else if (!surname.equals(other.surname)) - return false; - if (userIconPath == null) { - if (other.userIconPath != null) - return false; - } else if (!userIconPath.equals(other.userIconPath)) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (username == null) { - if (other.username != null) - return false; - } else if (!username.equals(other.username)) - return false; - return true; + return (ObjectUtils.objectsEqual(id, other.id) + && ObjectUtils.objectsEqual(department, other.department) + && ObjectUtils.objectsEqual(desktopDevice, other.desktopDevice) + && ObjectUtils.objectsEqual(domain, other.domain) + && ObjectUtils.objectsEqual(email, other.email) + && ObjectUtils.objectsEqual(groups, other.groups) + && lastAdminCheckStatus == other.lastAdminCheckStatus + && ObjectUtils.objectsEqual(name, other.name) + && ObjectUtils.objectsEqual(note, other.note) + && ObjectUtils.objectsEqual(role, other.role) + && status == other.status + && ObjectUtils.objectsEqual(surname, other.surname) + && ObjectUtils.objectsEqual(userIconPath, other.userIconPath) + && ObjectUtils.objectsEqual(username, other.username)); } public String getdepartment() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Disk.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Disk.java index d99b8a8..6918352 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Disk.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Disk.java @@ -2,6 +2,7 @@ import java.util.ArrayList; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; /** @@ -93,28 +94,20 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Disk other = (Disk) obj; - if (plugged == null) { - if (other.plugged != null) - return false; - } else if (!plugged.equals(other.plugged)) - return false; - if (vmNames == null) { - if (other.vmNames != null) - return false; - } else if (!vmNames.equals(other.vmNames)) - return false; - if (vmEntityType != other.vmEntityType) - return false; - if (numberOfVms != other.numberOfVms) - return false; - return true; + return (ObjectUtils.objectsEqual(plugged, other.plugged) + && ObjectUtils.objectsEqual(vmNames, other.vmNames) + && vmEntityType == other.vmEntityType + && numberOfVms == other.numberOfVms); } public int getNumberOfVms() { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java index 5118ff1..3ea57de 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImage.java @@ -4,6 +4,7 @@ import java.util.Date; import java.util.List; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.NGuid; @@ -433,79 +434,32 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (!super.equals(obj)) + } + if (!super.equals(obj)) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } DiskImage other = (DiskImage) obj; - if (getImage() == null) { - if (other.getImage() != null) - return false; - } else if (!getImage().equals(other.getImage())) - return false; - if (snapshots == null) { - if (other.snapshots != null) - return false; - } else if (!snapshots.equals(other.snapshots)) - return false; - if (actualSizeFromDiskImageDynamic != other.actualSizeFromDiskImageDynamic) - return false; - if (appList == null) { - if (other.appList != null) - return false; - } else if (!appList.equals(other.appList)) - return false; - if (description == null) { - if (other.description != null) - return false; - } else if (!description.equals(other.description)) - return false; - if (readRateKbPerSec != other.readRateKbPerSec) - return false; - if (writeRateKbPerSec != other.writeRateKbPerSec) - return false; - if (storagePath == null) { - if (other.storagePath != null) - return false; - } else if (!storagePath.equals(other.storagePath)) - return false; - if (readRateFromDiskImageDynamic != other.readRateFromDiskImageDynamic) - return false; - if (storageIds == null) { - if (other.storageIds != null) - return false; - } else if (!storageIds.equals(other.storageIds)) - return false; - if (storagePoolId == null) { - if (other.storagePoolId != null) - return false; - } else if (!storagePoolId.equals(other.storagePoolId)) - return false; - if (storagesNames == null) { - if (other.storagesNames != null) - return false; - } else if (!storagesNames.equals(other.storagesNames)) - return false; - if (writeRateFromDiskImageDynamic != other.writeRateFromDiskImageDynamic) - return false; - if (readLatency == null) { - if (other.readLatency != null) - return false; - } else if (!readLatency.equals(other.readLatency)) - return false; - if (writeLatency == null) { - if (other.writeLatency != null) - return false; - } else if (!writeLatency.equals(other.writeLatency)) - return false; - if (flushLatency == null) { - if (other.flushLatency != null) - return false; - } else if (!flushLatency.equals(other.flushLatency)) - return false; - return true; + return (ObjectUtils.objectsEqual(getImage(), other.getImage()) + && ObjectUtils.objectsEqual(snapshots, other.snapshots) + && actualSizeFromDiskImageDynamic == other.actualSizeFromDiskImageDynamic + && ObjectUtils.objectsEqual(appList, other.appList) + && ObjectUtils.objectsEqual(description, other.description) + && readRateKbPerSec == other.readRateKbPerSec + && writeRateKbPerSec == other.writeRateKbPerSec + && ObjectUtils.objectsEqual(storagePath, other.storagePath) + && readRateFromDiskImageDynamic == other.readRateFromDiskImageDynamic + && ObjectUtils.objectsEqual(storageIds, other.storageIds) + && ObjectUtils.objectsEqual(storagePoolId, other.storagePoolId) + && ObjectUtils.objectsEqual(storagesNames, other.storagesNames) + && writeRateFromDiskImageDynamic == other.writeRateFromDiskImageDynamic + && ObjectUtils.objectsEqual(readLatency, other.readLatency) + && ObjectUtils.objectsEqual(writeLatency, other.writeLatency) + && ObjectUtils.objectsEqual(flushLatency, other.flushLatency)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImageDynamic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImageDynamic.java index 6f759ea..b0601b8 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImageDynamic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskImageDynamic.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.common.businessentities; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class DiskImageDynamic implements BusinessEntity<Guid>, Comparable<DiskImageDynamic> { @@ -86,46 +87,23 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } DiskImageDynamic other = (DiskImageDynamic) obj; - if (actualSize != other.actualSize) - return false; - if (id == null) { - if (other.id != null) - return false; - } else if (!id.equals(other.id)) - return false; - if (readRate == null) { - if (other.readRate != null) - return false; - } else if (!readRate.equals(other.readRate)) - return false; - if (writeRate == null) { - if (other.writeRate != null) - return false; - } else if (!writeRate.equals(other.writeRate)) - return false; - if (readLatency == null) { - if (other.readLatency != null) - return false; - } else if (!readLatency.equals(other.readLatency)) - return false; - if (writeLatency == null) { - if (other.writeLatency != null) - return false; - } else if (!writeLatency.equals(other.writeLatency)) - return false; - if (flushLatency == null) { - if (other.flushLatency != null) - return false; - } else if (!flushLatency.equals(other.flushLatency)) - return false; - return true; + return (ObjectUtils.objectsEqual(id, other.id) + && actualSize == other.actualSize + && ObjectUtils.objectsEqual(readRate, other.readRate) + && ObjectUtils.objectsEqual(writeRate, other.writeRate) + && ObjectUtils.objectsEqual(readLatency, other.readLatency) + && ObjectUtils.objectsEqual(writeLatency, other.writeLatency) + && ObjectUtils.objectsEqual(flushLatency, other.flushLatency)); } @Override diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMap.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMap.java index aadcc71..62190c9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMap.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMap.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.common.businessentities; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class DiskLunMap implements BusinessEntity<DiskLunMapId> { @@ -59,13 +60,6 @@ return false; } DiskLunMap other = (DiskLunMap) obj; - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(id, other.id)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMapId.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMapId.java index a72c54a..a7364f9 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMapId.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/DiskLunMapId.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class DiskLunMapId implements Serializable { @@ -57,21 +58,8 @@ return false; } DiskLunMapId other = (DiskLunMapId) obj; - if (diskId == null) { - if (other.diskId != null) { - return false; - } - } else if (!diskId.equals(other.diskId)) { - return false; - } - if (lunId == null) { - if (other.lunId != null) { - return false; - } - } else if (!lunId.equals(other.lunId)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(diskId, other.diskId) + && ObjectUtils.objectsEqual(lunId, other.lunId)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Image.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Image.java index dc681e6..7bc795f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Image.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/Image.java @@ -4,6 +4,7 @@ import javax.validation.constraints.NotNull; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.validation.group.CreateEntity; import org.ovirt.engine.core.common.validation.group.UpdateEntity; import org.ovirt.engine.core.compat.Guid; @@ -207,47 +208,12 @@ return false; } Image other = (Image) obj; - if (active != other.active) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - if (lastModified == null) { - if (other.lastModified != null) { - return false; - } - } else if (!lastModified.equals(other.lastModified)) { - return false; - } - if (parentId == null) { - if (other.parentId != null) { - return false; - } - } else if (!parentId.equals(other.parentId)) { - return false; - } - if (snapshotId == null) { - if (other.snapshotId != null) { - return false; - } - } else if (!snapshotId.equals(other.snapshotId)) { - return false; - } - if (status != other.status) { - return false; - } - if (templateImageId == null) { - if (other.templateImageId != null) { - return false; - } - } else if (!templateImageId.equals(other.templateImageId)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(id, other.id) + && active == other.active + && ObjectUtils.objectsEqual(lastModified, other.lastModified) + && ObjectUtils.objectsEqual(parentId, other.parentId) + && ObjectUtils.objectsEqual(snapshotId, other.snapshotId) + && status == other.status + && ObjectUtils.objectsEqual(templateImageId, other.templateImageId)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStorageDomainMapId.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStorageDomainMapId.java index 4a638f0..97a4356 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStorageDomainMapId.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/ImageStorageDomainMapId.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class ImageStorageDomainMapId implements Serializable { @@ -16,24 +17,18 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ImageStorageDomainMapId other = (ImageStorageDomainMapId) obj; - if (imageId == null) { - if (other.imageId != null) - return false; - } else if (!imageId.equals(other.imageId)) - return false; - if (storageDomainId == null) { - if (other.storageDomainId != null) - return false; - } else if (!storageDomainId.equals(other.storageDomainId)) - return false; - return true; + return (ObjectUtils.objectsEqual(imageId, other.imageId) + && ObjectUtils.objectsEqual(storageDomainId, other.storageDomainId)); } private static final long serialVersionUID = -5870880575903017188L; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_notification_hist.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_notification_hist.java index 9d7b013..31233a8 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_notification_hist.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_notification_hist.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class event_notification_hist implements Serializable { @@ -107,42 +108,22 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } event_notification_hist other = (event_notification_hist) obj; - if (auditLogId != other.auditLogId) - return false; - if (eventName == null) { - if (other.eventName != null) - return false; - } else if (!eventName.equals(other.eventName)) - return false; - if (methodType == null) { - if (other.methodType != null) - return false; - } else if (!methodType.equals(other.methodType)) - return false; - if (reason == null) { - if (other.reason != null) - return false; - } else if (!reason.equals(other.reason)) - return false; - if (sentAt == null) { - if (other.sentAt != null) - return false; - } else if (!sentAt.equals(other.sentAt)) - return false; - if (status != other.status) - return false; - if (subscriberId == null) { - if (other.subscriberId != null) - return false; - } else if (!subscriberId.equals(other.subscriberId)) - return false; - return true; + return (auditLogId == other.auditLogId + && ObjectUtils.objectsEqual(subscriberId, other.subscriberId) + && ObjectUtils.objectsEqual(eventName, other.eventName) + && ObjectUtils.objectsEqual(methodType, other.methodType) + && ObjectUtils.objectsEqual(reason, other.reason) + && ObjectUtils.objectsEqual(sentAt, other.sentAt) + && status == other.status); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber.java index 310896f..cf9bd1f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber.java @@ -3,6 +3,7 @@ import java.io.Serializable; import org.hibernate.validator.constraints.Email; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.StringFormat; @@ -38,36 +39,21 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } event_subscriber other = (event_subscriber) obj; - if (id.eventUpName == null) { - if (other.id.eventUpName != null) - return false; - } else if (!id.eventUpName.equals(other.id.eventUpName)) - return false; - if (methodAddress == null) { - if (other.methodAddress != null) - return false; - } else if (!methodAddress.equals(other.methodAddress)) - return false; - if (id.methodId != other.id.methodId) - return false; - if (id.subscriberId == null) { - if (other.id.subscriberId != null) - return false; - } else if (!id.subscriberId.equals(other.id.subscriberId)) - return false; - if (id.tagName == null) { - if (other.id.tagName != null) - return false; - } else if (!id.tagName.equals(other.id.tagName)) - return false; - return true; + return (ObjectUtils.objectsEqual(id.eventUpName, other.id.eventUpName) + && ObjectUtils.objectsEqual(methodAddress, other.methodAddress) + && id.methodId == other.id.methodId + && ObjectUtils.objectsEqual(id.subscriberId, other.id.subscriberId) + && ObjectUtils.objectsEqual(id.tagName, other.id.tagName)); } public event_subscriber(String event_up_name, int method_id, Guid subscriber_id, String tagName) { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber_id.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber_id.java index 4fb565f..73049ac 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber_id.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/event_subscriber_id.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class event_subscriber_id implements Serializable { @@ -36,30 +37,19 @@ @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } event_subscriber_id other = (event_subscriber_id) obj; - if (eventUpName == null) { - if (other.eventUpName != null) - return false; - } else if (!eventUpName.equals(other.eventUpName)) - return false; - if (methodId != other.methodId) - return false; - if (subscriberId == null) { - if (other.subscriberId != null) - return false; - } else if (!subscriberId.equals(other.subscriberId)) - return false; - if (tagName == null) { - if (other.tagName != null) - return false; - } else if (!tagName.equals(other.tagName)) - return false; - return true; + return (ObjectUtils.objectsEqual(subscriberId, other.subscriberId) + && ObjectUtils.objectsEqual(eventUpName, other.eventUpName) + && methodId == other.methodId + && ObjectUtils.objectsEqual(tagName, other.tagName)); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_storage_domain_map.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_storage_domain_map.java index 89d2a0a..859211d 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_storage_domain_map.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_storage_domain_map.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.common.businessentities; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class image_storage_domain_map implements BusinessEntity<ImageStorageDomainMapId> { @@ -52,14 +53,7 @@ return false; } image_storage_domain_map other = (image_storage_domain_map) obj; - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(id, other.id)); } @Override diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map.java index 10fbae1..6256d3e 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.common.businessentities; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class image_vm_map implements BusinessEntity<image_vm_map_id> { @@ -62,21 +63,8 @@ return false; } image_vm_map other = (image_vm_map) obj; - if (active == null) { - if (other.active != null) { - return false; - } - } else if (!active.equals(other.active)) { - return false; - } - if (id == null) { - if (other.id != null) { - return false; - } - } else if (!id.equals(other.id)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(id, other.id) + && ObjectUtils.objectsEqual(active, other.active)); } /** diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map_id.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map_id.java index 1de1831..9ffd943 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map_id.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/image_vm_map_id.java @@ -2,6 +2,7 @@ import java.io.Serializable; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; public class image_vm_map_id implements Serializable { @@ -67,21 +68,8 @@ return false; } image_vm_map_id other = (image_vm_map_id) obj; - if (imageId == null) { - if (other.imageId != null) { - return false; - } - } else if (!imageId.equals(other.imageId)) { - return false; - } - if (vmId == null) { - if (other.vmId != null) { - return false; - } - } else if (!vmId.equals(other.vmId)) { - return false; - } - return true; + return (ObjectUtils.objectsEqual(imageId, other.imageId) + && ObjectUtils.objectsEqual(vmId, other.vmId)); } } -- To view, visit http://gerrit.ovirt.org/12342 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie9531a453a352619e8a6243ea1a5e4d0de4d1a45 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Greg Padgett <gpadg...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches