summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/layout
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2008-12-18 20:58:00 +0000
committerBrian S. O'Neill <bronee@gmail.com>2008-12-18 20:58:00 +0000
commitb66fb3db6951b2b6d3ace72ca3e197c7c2048e86 (patch)
treee5d9c0c6819f01b8917dcfb8884e07a3c8a9567b /src/main/java/com/amazon/carbonado/layout
parentc8133fcabf7a28b40f6bc8e4e4df8baf156b2f0a (diff)
Fixes for excessive class generation and memory usage when opening multiple repositories.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/layout')
-rw-r--r--src/main/java/com/amazon/carbonado/layout/Layout.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/layout/Layout.java b/src/main/java/com/amazon/carbonado/layout/Layout.java
index ca50172..b6c6c0d 100644
--- a/src/main/java/com/amazon/carbonado/layout/Layout.java
+++ b/src/main/java/com/amazon/carbonado/layout/Layout.java
@@ -394,6 +394,49 @@ public class Layout {
return reconstructed;
}
+ @Override
+ public int hashCode() {
+ long id = getLayoutID();
+ return ((int) id) ^ (int) (id >> 32);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Layout) {
+ Layout other = (Layout) obj;
+ try {
+ return mStoredLayout.equals(other.mStoredLayout) && equalLayouts(other);
+ } catch (FetchException e) {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder b = new StringBuilder();
+ b.append("Layout {type=").append(getStorableTypeName());
+ b.append(", generation=").append(getGeneration());
+ b.append(", properties={");
+ try {
+ List<LayoutProperty> props = getAllProperties();
+ for (int i=0; i<props.size(); i++) {
+ if (i > 0) {
+ b.append(", ");
+ }
+ b.append(props.get(i));
+ }
+ } catch (FetchException e) {
+ b.append(e.toString());
+ }
+ b.append("}}");
+ return b.toString();
+ }
+
/**
* Returns true if the given layout matches this one. Layout ID,
* generation, and creation info is not considered in the comparison.