From b66fb3db6951b2b6d3ace72ca3e197c7c2048e86 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Thu, 18 Dec 2008 20:58:00 +0000 Subject: Fixes for excessive class generation and memory usage when opening multiple repositories. --- .../java/com/amazon/carbonado/layout/Layout.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/main/java/com/amazon/carbonado/layout') 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 props = getAllProperties(); + for (int i=0; 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. -- cgit v1.2.3