package $class.packageName;
import java.util.Date;
public class $class.className implements java.io.Serializable{
//primary key
$class.Id.Property.ClassName $class.Id.Property.JavaName ;
//prop
#foreach ($prop in $class.Properties)
${prop.ClassName} $prop.JavaName ;
#end
public ${class.id.Property.ClassName} ${class.id.Property.GetterName}(){
return ${class.id.Property.JavaName};
}
public void ${class.id.Property.SetterName}(${class.id.Property.ClassName} value){
${class.id.Property.JavaName} = value;
}
#foreach ($prop in $class.Properties)
public ${prop.ClassName} ${prop.GetterName}(){
return ${prop.JavaName};
}
public void ${prop.SetterName}(${prop.ClassName} value){
${prop.JavaName} = value;
}
#end
public String toString(){
return "${class.ClassName} : "+${class.Id.Property.JavaName};
}
private int hashCode = Integer.MIN_VALUE;
#if ($class.Id || $class.AlternateKeys.size() > 0)
#if ($class.Id.hasExternalClass())
public int hashCode () {
if (Integer.MIN_VALUE == this.hashCode) {
#if ($class.AlternateKeys.size() == 0)
#if ($class.Id.Property.isPrimitive())
return (int) this.${class.Id.Property.GetterName}();
#else
if (null == this.${class.Id.Property.GetterName}()) return super.hashCode();
else {
String hashStr = this.getClass().getName() + ":" + this.${class.Id.Property.GetterName}().hashCode();
this.hashCode = hashStr.hashCode();
}
#end
#else
StringBuffer hashStr = new StringBuffer();
hashStr.append(this.getClass().getName() + ":");
#foreach ($prop in $class.AlternateKeys)
#if ($prop.isPrimitive())
hashStr.append(new ${prop.ObjectClass}(this.${prop.GetterName}()).toString() + ":");
#else
if (null == this.${prop.GetterName}()) return super.hashCode();
else hashStr.append(this.${prop.GetterName}().toString() + ":");
#end
#end
this.hashCode = hashStr.toString().hashCode();
#end
}
return this.hashCode;
}
#else
public int hashCode () {
if (Integer.MIN_VALUE == this.hashCode) {
StringBuffer sb = new StringBuffer();
#foreach ($prop in $class.Id.Properties)
#if ($prop.isPrimitive())
sb.append(new $!{prop.ObjectClass}(this.${prop.GetterName}()).hashCode());
sb.append(":");
#else
if (null != this.${prop.GetterName}()) {
sb.append(this.${prop.GetterName}().hashCode());
sb.append(":");
}
else {
return super.hashCode();
}
#end
#end
this.hashCode = sb.toString().hashCode();
}
return this.hashCode;
}
#end
#end
#if ($class.Id || $class.AlternateKeys.size() > 0)
#if ($class.Id.hasExternalClass())
public boolean equals (Object obj) {
if (null == obj) return false;
if (!(obj instanceof ${class.ClassName})) return false;
else {
${class.ClassName} mObj = (${class.ClassName}) obj;
#if ($class.AlternateKeys.size() == 0)
#if ($class.Id.Property.isPrimitive())
return (this.${class.Id.Property.GetterName}() == mObj.${class.Id.Property.GetterName}());
#else
if (null == this.${class.Id.Property.GetterName}() || null == mObj.${class.Id.Property.GetterName}()) return false;
else return (this.${class.Id.Property.GetterName}().equals(mObj.${class.Id.Property.GetterName}()));
#end
#else
boolean isEqual = true;
#foreach ($prop in $class.AlternateKeys)
#if ($prop.isPrimitive())
isEqual = isEqual && (this.${prop.GetterName}() == mObj.${prop.GetterName}());
#else
if (null == this.${prop.GetterName}() || null == mObj.${prop.GetterName}()) return false;
else isEqual = isEqual && (this.${prop.GetterName}().equals(mObj.${prop.GetterName}()));
#end
#end
return isEqual;
#end
}
}
#else
public boolean equals (Object obj) {
if (null == obj) return false;
if (!(obj instanceof ${class.ClassName})) return false;
else {
${class.ClassName} mObj = (${class.ClassName}) obj;
#foreach ($prop in $class.Id.Properties)
#if ($prop.isPrimitive())
if (this.${prop.GetterName}() != mObj.${prop.GetterName}()) {
return false;
}
#else
if (null != this.${prop.GetterName}() && null != mObj.${prop.GetterName}()) {
if (!this.${prop.GetterName}().equals(mObj.${prop.GetterName}())) {
return false;
}
}
else {
return false;
}
#end
#end
#if ($class.Id.Properties.size() > 0)
return true;
#else
return super.equals(obj);
#end
}
}
#end
#end
}