Martin Peřina has uploaded a new change for review. Change subject: core: Add equals() and hashcode() to FenceAgent ......................................................................
core: Add equals() and hashcode() to FenceAgent Adds missing equals() and hashcode() methods to FenceAgent. Change-Id: Ic994171f66a23bba1706a2d10793f0af04e265b7 Bug-Url: https://bugzilla.redhat.com/1182510 Signed-off-by: Martin Perina <[email protected]> --- M backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/ConcurrentAgentsFenceActionExecutorTest.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceAgent.java 2 files changed, 42 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/39510/1 diff --git a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/ConcurrentAgentsFenceActionExecutorTest.java b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/ConcurrentAgentsFenceActionExecutorTest.java index 13e718f..9576dd4 100644 --- a/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/ConcurrentAgentsFenceActionExecutorTest.java +++ b/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/pm/ConcurrentAgentsFenceActionExecutorTest.java @@ -24,6 +24,7 @@ import org.ovirt.engine.core.common.businessentities.pm.FenceOperationResult.Status; import org.ovirt.engine.core.common.businessentities.pm.PowerStatus; import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.utils.MockConfigRule; @RunWith(MockitoJUnitRunner.class) @@ -53,7 +54,9 @@ @Before public void setup() { agent1 = new FenceAgent(); + agent1.setId(Guid.newGuid()); agent2 = new FenceAgent(); + agent2.setId(Guid.newGuid()); List<FenceAgent> fenceAgents = new ArrayList<>(); fenceAgents.add(agent1); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceAgent.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceAgent.java index 7121f70..f3d4b7a 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceAgent.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/FenceAgent.java @@ -8,6 +8,7 @@ import javax.validation.constraints.Size; import org.hibernate.validator.constraints.Range; +import org.ovirt.engine.core.common.utils.ObjectUtils; import org.ovirt.engine.core.common.utils.ToStringBuilder; import org.ovirt.engine.core.common.validation.annotation.HostnameOrIp; import org.ovirt.engine.core.common.validation.group.PowerManagementCheck; @@ -236,6 +237,44 @@ .build(); } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof FenceAgent)) { + return false; + } + FenceAgent other = (FenceAgent) obj; + return ObjectUtils.objectsEqual(id, other.id) + && ObjectUtils.objectsEqual(hostId, other.hostId) + && order == other.order + && ObjectUtils.objectsEqual(type, other.type) + && ObjectUtils.objectsEqual(ip, other.ip) + && ObjectUtils.objectsEqual(port, other.port) + && ObjectUtils.objectsEqual(user, other.user) + && ObjectUtils.objectsEqual(password, other.password) + && encryptOptions == other.encryptOptions + && ObjectUtils.objectsEqual(options, other.options); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + (id == null ? 0 : id.hashCode()); + result = prime * result + (hostId == null ? 0 : hostId.hashCode()); + result = prime * result + order; + result = prime * result + (type == null ? 0 : type.hashCode()); + result = prime * result + (ip == null ? 0 : ip.hashCode()); + result = prime * result + (port == null ? 0 : port.hashCode()); + result = prime * result + (user == null ? 0 : user.hashCode()); + result = prime * result + (password == null ? 0 : password.hashCode()); + result = prime * result + (encryptOptions ? 1 : 0); + result = prime * result + (options == null ? 0 : options.hashCode()); + return result; + } + public static class FenceAgentOrderComparator implements Comparator<FenceAgent> { @Override -- To view, visit https://gerrit.ovirt.org/39510 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ic994171f66a23bba1706a2d10793f0af04e265b7 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Peřina <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
