Here you can find the source of toString(Object obj)
Parameter | Description |
---|---|
obj | the object. |
static String toString(Object obj)
//package com.java2s; import java.util.List; public class Main { /**//from w w w . j a v a 2 s . c o m * Converts the object to a string. * * @param obj * the object. * * @return the string. */ static String toString(Object obj) { // if (obj instanceof IdentifiableEntity) { // // IdentifiableEntity // return ((IdentifiableEntity) obj).toJSONString(); // // } else if (obj instanceof TcDirectProject) { // // TcDirectProject // return ((TcDirectProject) obj).toJSONString(); // } else if (obj instanceof DirectProjectFilter) { // // DirectProjectFilter // return ((DirectProjectFilter) obj).toJSONString(); // } else if (obj instanceof DirectProjectMetadataDTO) { // // DirectProjectMetadataDTO // return ((DirectProjectMetadataDTO) obj).toJSONString(); // } else if (obj instanceof List<?>) { // // DirectProjectMetadataDTO // return toString((List<?>) obj); // } return "";//String.valueOf(obj); } /** * Converts the List to a string. * * @param obj * the List (not <code>null</code>). * * @return the string. */ private static String toString(List<?> obj) { StringBuilder sb = new StringBuilder("["); boolean first = true; for (Object element : obj) { if (!first) { // Append a comma sb.append(", "); } first = false; sb.append(toString(element)); } sb.append("]"); return sb.toString(); } }