diff options
author | Brian Vosburgh | 2013-08-15 23:03:00 +0000 |
---|---|---|
committer | Brian Vosburgh | 2013-08-26 19:12:19 +0000 |
commit | f378e79584984c711936b1205c880a7cc717f3cf (patch) | |
tree | e4cd13fbf24b93921f8ccf91f03798447f84ad8f /common | |
parent | cdde9085d170c803438832884e41b68390d08b26 (diff) | |
download | webtools.dali-f378e79584984c711936b1205c880a7cc717f3cf.tar.gz webtools.dali-f378e79584984c711936b1205c880a7cc717f3cf.tar.xz webtools.dali-f378e79584984c711936b1205c880a7cc717f3cf.zip |
add ObjectTools.identityToString(Object) and
StringBuilderTools.appendIdentityToString(StringBuilder, Object)
Diffstat (limited to 'common')
2 files changed, 26 insertions, 0 deletions
diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java index b10a354789..9237cddab8 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/ObjectTools.java @@ -269,6 +269,19 @@ public final class ObjectTools { } /** + * Build a "Java standard" {@link Object#toString() toString()} result for + * the specified object:<pre> + * package.ClassName@F3EE42 + * </pre> + * @see Object#toString() + */ + public static String identityToString(Object object) { + StringBuilder sb = new StringBuilder(); + StringBuilderTools.appendIdentityToString(sb, object); + return sb.toString(); + } + + /** * Return a string suitable for a <em>singleton</em>; which is the simple * name of the object's class, since there should only be one. * diff --git a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringBuilderTools.java b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringBuilderTools.java index 6c6ecf45d3..446e45062c 100644 --- a/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringBuilderTools.java +++ b/common/plugins/org.eclipse.jpt.common.utility/src/org/eclipse/jpt/common/utility/internal/StringBuilderTools.java @@ -1992,6 +1992,19 @@ public final class StringBuilderTools { ClassTools.appendToStringNameTo(javaClass, sb); } + /** + * Append a "Java standard" {@link Object#toString() toString()} result for + * the specified object to the specified string builder:<pre> + * package.ClassName@F3EE42 + * </pre> + * @see Object#toString() + */ + public static void appendIdentityToString(StringBuilder sb, Object object) { + sb.append(object.getClass().getName()); + sb.append('@'); + sb.append(Integer.toHexString(object.hashCode())); + } + // ********** constructor ********** |