Java Identity to String identityToString(StringBuffer buffer, Object object)

Here you can find the source of identityToString(StringBuffer buffer, Object object)

Description

identity To String

License

Mozilla Public License

Declaration

public static void identityToString(StringBuffer buffer, Object object) 

Method Source Code

//package com.java2s;
//License from project: Mozilla Public License 

public class Main {
    public static String identityToString(Object object) {
        if (object == null) {
            return null;
        }//  w w w  . j  ava  2 s  .com

        StringBuffer buffer = new StringBuffer();

        identityToString(buffer, object);

        return buffer.toString();
    }

    public static void identityToString(StringBuffer buffer, Object object) {
        if (object == null) {
            throw new NullPointerException("Cannot get the toString of a null identity");
        }

        buffer.append(object.getClass().getName()).append('@')
                .append(Integer.toHexString(System.identityHashCode(object)));
    }

    public static String toString(Object obj) {
        return obj == null ? "" : obj.toString();
    }

    public static String toString(Object obj, String nullStr) {
        return obj == null ? nullStr : obj.toString();
    }
}

Related

  1. identityToString(final Object obj)
  2. identityToString(Object obj)
  3. identityToString(Object obj)
  4. identityToString(Object obj)
  5. identityToString(Object pObject)
  6. identityToSubject(String identity)