modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
| 5 +-
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
| 21 +++++-----
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
| 18 +++++++-
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
| 12 +++++
modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
| 3 -
5 files changed, 46 insertions(+), 13 deletions(-)
New commits:
commit a1d95800d25edf92c3a9f96e3f27a133f93ad1b4
Author: Jay Shaughnessy <jshaughn(a)redhat.com>
Date: Tue Dec 21 11:43:48 2010 -0500
Some tweaks to Bundle Domain objects.
- add some missing null protection in toString()
- remove ctime from BundleDeployment hashCode as it's not part of the
natural key and could cause issues due to the way its initialized at
construction-time.
- for relevant entities add some jdoc for hashcode/equals impls noting
the use of lazy loaded fields in the natural key. This should not be a
problem for real-work scenarios but is a subtlety that may need to be
made clear, especially for test code.
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
index 6dd4a02..9bf477f 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/Bundle.java
@@ -217,7 +217,10 @@ public class Bundle implements Serializable {
@Override
public String toString() {
- return "Bundle[id=" + id + ",name=" + name +
",bundleType=" + bundleType + ",packageType=" + packageType +
"]";
+ return "Bundle[id=" + id //
+ + ",name=" + name //
+ + ",bundleType=" + bundleType //
+ + ",packageType=" + packageType + "]";
}
@Override
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
index c2a062b..fc0c72c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDeployment.java
@@ -360,6 +360,12 @@ public class BundleDeployment implements Serializable {
return "BundleDeployment[id=" + id + ", name=" + name +
"]";
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -367,10 +373,15 @@ public class BundleDeployment implements Serializable {
result = prime * result + ((this.bundleVersion == null) ? 0 :
this.bundleVersion.hashCode());
result = prime * result + ((this.destination == null) ? 0 :
this.destination.hashCode());
result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
- result = prime * result + ((this.ctime == null) ? 0 : this.ctime.hashCode());
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
@@ -406,14 +417,6 @@ public class BundleDeployment implements Serializable {
return false;
}
- if (this.ctime == null) {
- if (other.ctime != null) {
- return false;
- }
- } else if (!this.ctime.equals(other.ctime)) {
- return false;
- }
-
return true;
}
}
\ No newline at end of file
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
index 5c37ebf..dc730c7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleDestination.java
@@ -224,10 +224,18 @@ public class BundleDestination implements Serializable {
@Override
public String toString() {
- return "BundleDestination[id=" + id + ", bundle=" +
bundle.getName() + ", group=" + group.getName() + ", name="
- + name + "]";
+ return "BundleDestination[id=" + id //
+ + ((null != bundle) ? (", bundle=" + bundle.getName()) :
"") //
+ + ((null != group) ? (", group=" + group.getName()) : "")
//
+ + ", name=" + name + "]";
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
final int prime = 31;
@@ -238,6 +246,12 @@ public class BundleDestination implements Serializable {
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
index 1bc3c25..7cd7b50 100644
---
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
+++
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleResourceDeployment.java
@@ -172,6 +172,12 @@ public class BundleResourceDeployment implements Serializable {
return str.toString();
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#hashCode()
+ */
@Override
public int hashCode() {
int result = 1;
@@ -180,6 +186,12 @@ public class BundleResourceDeployment implements Serializable {
return result;
}
+ /*
+ * These fields make up the natural key but note that some fields are lazy loaded. As
such care should
+ * be taken to have properly loaded instances when required.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
@Override
public boolean equals(Object obj) {
if (this == obj) {
diff --git
a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
index 0afdb13..cfbb9d7 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/bundle/BundleVersion.java
@@ -261,7 +261,8 @@ public class BundleVersion implements Serializable {
@Override
public String toString() {
- return "BundleVersion[id=" + id + ",name=" + name +
",version=" + version + ",bundle=" + bundle.getName() +
"]";
+ return "BundleVersion[id=" + id + ",name=" + name +
",version=" + version
+ + ((null != bundle) ? (",bundle=" + bundle.getName()) :
"") + "]";
}
@Override
Show replies by date