Allon Mureinik has uploaded a new change for review. Change subject: core: Use java.util.Objects.equals(Object, Object) ......................................................................
core: Use java.util.Objects.equals(Object, Object) This patch replaces usages of org.ovirt.engine.core.common.utils.ObjectUtils.equals(Object, Object) with the standard JDK7 java.util.Objects.equals(Object, Object) wherever possible (i.e., no GWT compilation is required). This patch helps standardize the code, makes it slightly more readable to novice oVirt developers and may even save a pico-second of performance. Change-Id: Ifbce02996fbba804aeabc54a13f2109656f4a2c6 Signed-off-by: Allon Mureinik <amure...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UniquePermissionsSet.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/attestation/AttestationValue.java 5 files changed, 16 insertions(+), 16 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/22979/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UniquePermissionsSet.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UniquePermissionsSet.java index 6f14b3f..7d13356 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UniquePermissionsSet.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UniquePermissionsSet.java @@ -3,9 +3,9 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; +import java.util.Objects; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.businessentities.Permissions; -import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.compat.Guid; /** @@ -68,8 +68,8 @@ return false; } Permissions other = (Permissions) obj; - return (ObjectUtils.objectsEqual(getad_element_id(), other.getad_element_id()) - && ObjectUtils.objectsEqual(getrole_id(), other.getrole_id()) - && ObjectUtils.objectsEqual(getObjectId(), other.getObjectId())); + return Objects.equals(getad_element_id(), other.getad_element_id()) + && Objects.equals(getrole_id(), other.getrole_id()) + && Objects.equals(getObjectId(), other.getObjectId()); } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java index 8dfdfa4..2b56a1a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVdsGroupCommand.java @@ -2,6 +2,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.utils.VersionSupport; @@ -28,7 +29,6 @@ import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported; import org.ovirt.engine.core.common.utils.ListUtils; -import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.validation.group.UpdateEntity; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.Version; @@ -58,7 +58,7 @@ // TODO: This code should be revisited and proper compensation logic should be introduced here checkMaxMemoryOverCommitValue(); - if (!ObjectUtils.objectsEqual(oldGroup.getcompatibility_version(), getParameters().getVdsGroup().getcompatibility_version())) { + if (!Objects.equals(oldGroup.getcompatibility_version(), getParameters().getVdsGroup().getcompatibility_version())) { String emulatedMachine = null; // pick an UP host randomly - all should have latest compat version already if we passed the canDo. for (VDS vds : allForVdsGroup) { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java index 5163055..3ed9e0f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java @@ -7,6 +7,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Objects; import org.apache.commons.lang.StringUtils; import org.ovirt.engine.core.bll.job.ExecutionHandler; @@ -40,7 +41,6 @@ import org.ovirt.engine.core.common.businessentities.network.VmNic; import org.ovirt.engine.core.common.errors.VdcBllMessages; import org.ovirt.engine.core.common.locks.LockingGroup; -import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.utils.transaction.TransactionMethod; @@ -354,7 +354,7 @@ protected void updateQuota(DiskImage diskImage) { if (isQuotaValidationNeeded()) { DiskImage oldDisk = (DiskImage) getOldDisk(); - if (!ObjectUtils.objectsEqual(oldDisk.getQuotaId(), diskImage.getQuotaId())) { + if (!Objects.equals(oldDisk.getQuotaId(), diskImage.getQuotaId())) { getImageStorageDomainMapDao().updateQuotaForImageAndSnapshots(diskImage.getId(), diskImage.getStorageIds().get(0), diskImage.getQuotaId()); @@ -537,7 +537,7 @@ return false; } Guid oldQuotaId = ((DiskImage) getOldDisk()).getQuotaId(); - return !ObjectUtils.objectsEqual(oldQuotaId, getQuotaId()); + return !Objects.equals(oldQuotaId, getQuotaId()); } protected boolean shouldUpdateReadOnly() { diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java index 89f390b..fc14cc5 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/gluster/GlusterSyncJob.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import org.ovirt.engine.core.bll.Backend; @@ -31,7 +32,6 @@ import org.ovirt.engine.core.common.constants.gluster.GlusterConstants; import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported; import org.ovirt.engine.core.common.utils.ListUtils; -import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.utils.gluster.GlusterCoreUtil; import org.ovirt.engine.core.common.vdscommands.RemoveVdsVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; @@ -569,7 +569,7 @@ } } else { // brick found. update it if required. Only property that could be different is the brick order - if (!ObjectUtils.objectsEqual(existingBrick.getBrickOrder(), fetchedBrick.getBrickOrder())) { + if (!Objects.equals(existingBrick.getBrickOrder(), fetchedBrick.getBrickOrder())) { log.infoFormat("Brick order for brick {0} changed from {1} to {2} because of direct CLI operations. Updating engine DB accordingly.", existingBrick.getQualifiedName(), existingBrick.getBrickOrder(), @@ -725,13 +725,13 @@ } if (existingVolume.getVolumeType().isReplicatedType() && - !ObjectUtils.objectsEqual(existingVolume.getReplicaCount(), fetchedVolume.getReplicaCount())) { + !Objects.equals(existingVolume.getReplicaCount(), fetchedVolume.getReplicaCount())) { existingVolume.setReplicaCount(fetchedVolume.getReplicaCount()); changed = true; } if (existingVolume.getVolumeType().isStripedType() && - !ObjectUtils.objectsEqual(existingVolume.getStripeCount(), fetchedVolume.getStripeCount())) { + !Objects.equals(existingVolume.getStripeCount(), fetchedVolume.getStripeCount())) { existingVolume.setStripeCount(fetchedVolume.getStripeCount()); changed = true; } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/attestation/AttestationValue.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/attestation/AttestationValue.java index 8092230..0b234e1 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/attestation/AttestationValue.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/attestation/AttestationValue.java @@ -1,7 +1,7 @@ package org.ovirt.engine.core.vdsbroker.attestation; +import java.util.Objects; import org.ovirt.engine.core.common.businessentities.AttestationResultEnum; -import org.ovirt.engine.core.common.utils.ObjectUtils; public class AttestationValue { @@ -51,8 +51,8 @@ if (obj == null || (obj.getClass() != this.getClass())) return false; AttestationValue other = (AttestationValue) obj; - return (ObjectUtils.objectsEqual(hostName, other.hostName) - && ObjectUtils.objectsEqual(trustLevel, other.trustLevel)); + return Objects.equals(hostName, other.hostName) + && Objects.equals(trustLevel, other.trustLevel); } } -- To view, visit http://gerrit.ovirt.org/22979 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifbce02996fbba804aeabc54a13f2109656f4a2c6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Allon Mureinik <amure...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches