diff options
author | Andrey Loskutov | 2017-09-19 15:55:39 +0000 |
---|---|---|
committer | Andrey Loskutov | 2017-09-19 16:10:24 +0000 |
commit | 183b6192122c05d9489d771c6224ee626fe4df73 (patch) | |
tree | 6f2dccdbc5abe14f1403e0cd4f93d3a71f1a5ae0 | |
parent | db57ba861f17c017cec20140026089d8c181f14d (diff) | |
download | rt.equinox.bundles-183b6192122c05d9489d771c6224ee626fe4df73.tar.gz rt.equinox.bundles-183b6192122c05d9489d771c6224ee626fe4df73.tar.xz rt.equinox.bundles-183b6192122c05d9489d771c6224ee626fe4df73.zip |
Bug 515588 - [registry] Add toString() to ConfigurationElementHandleI20170920-0100I20170919-2000
This change implement meaningful and backwards compatible toString() in
a way that clients will not be broken like in bug 515405 comment 6.
Change-Id: I2d010d4da46b82edf88e77fa148f1fde0aae198d
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
-rw-r--r-- | bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java index 6eda9db7d..ed0a14322 100644 --- a/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java +++ b/bundles/org.eclipse.equinox.registry/src/org/eclipse/core/internal/registry/ConfigurationElementHandle.java @@ -165,4 +165,33 @@ public class ConfigurationElementHandle extends Handle implements IConfiguration public int getHandleId() { return getId(); } + + /** + * <b>WARNING</b>: this method <b>must</b> return string containing {@link #getHandleId()} identifier, because some clients might have + * misused previously returned {@link Object#toString()} value which was in fact just {@link #hashCode()} value which + * in turn was alwas the value of {@link #getHandleId()}. + * <p> + * Please read <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=515587#c0">bug 515587</a> for details. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("ConfigurationElementHandle ["); //$NON-NLS-1$ + sb.append("name: "); //$NON-NLS-1$ + sb.append(getName()); + String id = getAttribute("id"); //$NON-NLS-1$ + if (id != null && id.length() > 0) { + sb.append(", id: ").append(id); //$NON-NLS-1$ + } + String value = getValue(); + if (value != null) { + sb.append(", value: ").append(value); //$NON-NLS-1$ + } + sb.append(", handle id: ").append(getHandleId()); //$NON-NLS-1$ + sb.append(", namespace: "); //$NON-NLS-1$ + sb.append(getNamespaceIdentifier()); + sb.append("]"); //$NON-NLS-1$ + return sb.toString(); + } + } |