标签:builder tostring date mit json each access object dea
1、toString JSON带父类toString
public java.lang.String toString() { final java.lang.StringBuilder sb = new java.lang.StringBuilder("{"); #set ($i = 0) #foreach ($member in $members) #if ($i == 0) sb.append("## #else sb.append(", ## #end #if ($member.string || $member.date) \"$member.name\":\"")## #else \"$member.name\":")## #end #if ($member.primitiveArray || $member.objectArray) .append(java.util.Arrays.toString($member.name)); #elseif ($member.string || $member.date) .append($member.accessor).append(‘\"‘); #else .append($member.accessor); #end #set ($i = $i + 1) #end sb.append(‘}‘); #if ( $class.hasSuper ) sb.append(super.toString()); #end return sb.toString(); }
2、toString JSON不带父类toString
public java.lang.String toString() { final java.lang.StringBuilder sb = new java.lang.StringBuilder("{"); #set ($i = 0) #foreach ($member in $members) #if ($i == 0) sb.append("## #else sb.append(", ## #end #if ($member.string || $member.date) \"$member.name\":\"")## #else \"$member.name\":")## #end #if ($member.primitiveArray || $member.objectArray) .append(java.util.Arrays.toString($member.name)); #elseif ($member.string || $member.date) .append($member.accessor).append(‘\"‘); #else .append($member.accessor); #end #set ($i = $i + 1) #end sb.append(‘}‘); return sb.toString(); }
标签:builder tostring date mit json each access object dea
原文地址:http://www.cnblogs.com/rslai/p/7859019.html