View Javadoc

1   /*
2    * $Id: ObjectUtils.java 7963 2007-08-21 08:53:15Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.util;
12  
13  public class ObjectUtils extends org.apache.commons.lang.ObjectUtils
14  {
15  
16      /**
17       * Like {@link #identityToString(Object)} but without the object's full package
18       * name.
19       * 
20       * @param obj the object for which the identity description is to be generated
21       * @return the object's identity description in the form of
22       *         "ClassName@IdentityCode" or "null" if the argument was null.
23       */
24      public static String identityToShortString(Object obj)
25      {
26          if (obj == null)
27          {
28              return "null";
29          }
30          else
31          {
32              return new StringBuffer(40).append(
33                      ClassUtils.getSimpleName(obj.getClass()))
34                      .append('@')
35                      .append(Integer.toHexString(System.identityHashCode(obj))
36                      ).toString();
37          }
38      }
39  
40  }