## ============================================================================ ## Filename : JavaBeanTemplate.vm ## Note(s) : This template is used to generate a Java Bean class based on ## a database table/view. ## ## Copyright (c) 2007-2008 ThinkUI Software Inc. All rights reserved. ## ============================================================================ ## ## **************************************************************************** ## The following variables are available in this template. For more ## information on any of the following variable, please refer to the user guide. ## **************************************************************************** ## $projectName ## $authorName ## $headerText ## $tableName ## $schemaName ## $className ## $equalsMethod ## $hashCodeMethod ## $toStringMethod ## $packageName ## $prjPkgName ## $prjClassPrefix ## $dataClass ## $superClassName ## $date ## $codeGen ## #if ($packageName) package $packageName; #end #parse( "ClassHeaderInclude.vm" ) import java.io.Serializable; import java.math.BigInteger; import java.sql.Timestamp; import java.sql.Date; #if ($equalsMethod)import org.apache.commons.lang.builder.EqualsBuilder; #end#if ($hashCodeMethod)import org.apache.commons.lang.builder.HashCodeBuilder; #end /** * Implements the ${className} Java Bean. */ public class ${className} extends ${superClassName} implements Serializable { // // Attributes. // #foreach( $attr in $dataClass.getAttributes() ) private $codeGen.getAttributeTypeValueClassName($attr.getType()) $codeGen.toVarName($attr.getName());#if ($attr.isRequired()) // required;#end #end /** * ${className} constructor. */ public ${className}() { super(); } // // Access methods. // #foreach( $attr in $dataClass.getAttributes() ) /** * @return the $attr.getCaption(). */ public final $codeGen.getAttributeTypeValueClassName($attr.getType()) get${codeGen.toTypeName($attr.getName())}() { return $codeGen.toVarName($attr.getName()); } /** * Sets the $attr.getCaption(). */ public final void set${codeGen.toTypeName($attr.getName())}($codeGen.getAttributeTypeValueClassName($attr.getType()) $codeGen.toVarName($attr.getName())) { this.$codeGen.toVarName($attr.getName()) = $codeGen.toVarName($attr.getName()); } #end #if ($equalsMethod) public final boolean equals(Object object) { boolean result = false; if (object instanceof ${className}) { ${className} that = (${className}) object; result = new EqualsBuilder(). #foreach( $attr in $dataClass.getAttributes() ) #if ($codeGen.isPKAttrName($dataClass, $attr.getName())) append(that.get${codeGen.toTypeName($attr.getName())}(), get${codeGen.toTypeName($attr.getName())}()). #end #end isEquals(); } return result; } #end #if ($hashCodeMethod) public final int hashCode() { int hashCode = new HashCodeBuilder(). #foreach( $attr in $dataClass.getAttributes() ) #if ($codeGen.isPKAttrName($dataClass, $attr.getName())) append(get${codeGen.toTypeName($attr.getName())}()). #end #end hashCode(); return hashCode; } #end #if ($toStringMethod) public final String toString() { StringBuffer sb = new StringBuffer("${className}{"); #set( $firstItem = 1 ) #foreach( $attr in $dataClass.getAttributes() ) #if ($firstItem == 1) #set( $firstItem = 0 ) #else sb.append(", ");#end sb.append("${attr.getName()}=");sb.append(get${codeGen.toTypeName($attr.getName())}()); #end sb.append("}"); return sb.toString(); } #end }