Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
JDBC type returned by the driver: $column.getJavaTypeAsTypeName()
*
*
* @return the value of $column.getVarName()
*/
#if(!$column.isDate() && !$column.isFloat())#swiftThriftField( $fieldIndex $null)#jacksonField($column.getVarName())#end
#if( $column.isDate() || $column.isFloat())#jacksonIgnore()#end
public $column.getJavaType() ${column.getGetMethod()}(){
#if($column.byteBufferAsString)
return gu.sql2java.Sql2javaSupport.toByteBuffer(${column.getVarName()});
#elseif($column.jsonJacksonRawValue)
return null == $column.varName ? null : ${column.varName}.toJSONString();
#else
return $column.getVarName();
#end
}
#if(($swiftBeanSupport || $jacksonBeanSupport ) && $column.isDate())
/**
* use Long to represent date type for thrift:swift support
* @see #${column.getGetMethod()}()
*/
#swiftThriftField($fieldIndex $null $column.getVarName())
#jacksonField($column.getVarName())
public $dateSerializeType ${column.getReadMethod()}(){
#if($dateSerializeType == "Long")
return null == $column.getVarName() ? null:${column.getVarName()}.getTime();
#elseif($dateSerializeType == "String")
/** output data time format string */
return gu.sql2java.Sql2javaSupport.formatDate($column.getVarName(),"$dateStringFormat");
#else
/** UNSUPPORTED dateSerializeType=$dateSerializeType */
#end
}
#end
#if(($swiftBeanSupport || $jacksonBeanSupport ) && $column.isFloat())
/**
* use Double to represent Float type for thrift:swift support
* @see #${column.getGetMethod()}()
*/
#swiftThriftField($fieldIndex $null $column.getVarName())
#jacksonField($column.getVarName())
public Double ${column.getReadMethod()}(){
return null == $column.getVarName() ? null:${column.getVarName()}.doubleValue();
}
#end
/**
* Setter method for {@link #$column.getVarName()}.
#if ( $column.useEqualsInSetter() )
* The new value is set only if equals() says it is different,
* or if one of either the new value or the current value is null.
* In case the new value is different, it is set and the field is marked as 'modified'.
#elseif ($column.hasCompareTo())
* The new value is set only if compareTo() says it is different,
* or if one of either the new value or the current value is null.
* In case the new value is different, it is set and the field is marked as 'modified'.
#else
* Attention, there will be no comparison with current value which
* means calling this method will mark the field as 'modified' in all cases.
#end
*
* @param newVal the new value#if( !$column.isAutoincrement() && $column.isNotNull())( NOT NULL)#end to be assigned to $column.getVarName()
*/
#if(!$column.isDate() && !$column.isFloat())#swiftThriftField2($column.getVarName())#jacksonField($column.getVarName())#end
#if($column.isDate() || $column.isFloat())#jacksonIgnore()#end
public void $column.getSetMethod()($column.getJavaType() newVal)
{
$column.bitORAssignExpression("modified");
$column.bitORAssignExpression("initialized");
#if($column.byteBufferAsString || !$column.jsonJacksonRawValue)
#if ($column.useEqualsInSetter())
if (Objects.equals(newVal, $column.getVarName())) {
return;
}
#elseif ($column.hasCompareTo())
if (equals(newVal, $column.getVarName())) {
return;
}
#end
#end
#if ( $column.hasPrimaryType() && $codewriter.getProperty('bean.compatible_axis2') )
#if($column.getJavaType()=='Integer')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Integer.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Long')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Long.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Byte')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Byte.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Double')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Double.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Float')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Float.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Character')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Character.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Short')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Short.MIN_VALUE?null:newVal;
#elseif($column.getJavaType()=='Boolean')
//compatible for axis2
$column.getVarName() = null==newVal||newVal==Boolean.FALSE?null:newVal;
#else
$column.getVarName() = newVal;
#end
#elseif($column.byteBufferAsString)
$column.varName = gu.sql2java.Sql2javaSupport.toString(newVal);
#elseif($column.jsonJacksonRawValue)
$column.varName = com.alibaba.fastjson.JSONObject.parseObject(newVal,${column.fieldJavaType}.class);
#else
$column.getVarName() = newVal;
#end###if ( $column.hasPrimaryType() && $codewriter.getProperty('bean.compatible_axis2') )
}
################ READ/WRITE METHOD FOR JSON FIELD###############
#if($column.jsonJacksonRawValue)
/**
* read method for {@link #$column.varName}
* @return the JSON value of $column.varName
*/
public $column.fieldJavaType ${column.ReadMethod}(){
return $column.varName;
}
/**
* write method for {@link #$column.varName} with JSON object.
*/
public void ${column.writeMethod}($column.fieldJavaType newVal){
$column.bitORAssignExpression("modified");
$column.bitORAssignExpression("initialized");
if (Objects.equals(newVal, $column.varName)) {
return;
}
$column.varName = newVal;
}
#end
################ SETTER METHOD FOR SWIFT OR JACKSON ###############
#if(($swiftBeanSupport || $jacksonBeanSupport ) && ($column.isDate() || $column.isFloat()))
/**
* setter for thrift:swift OR jackson support
* without modification for {@link ${esc.hash}modified} and {@link ${esc.hash}initialized}
* NOTE:DO NOT use the method in your code
*/
#if($column.isDate())
#swiftThriftField2($column.getVarName())
#jacksonField($column.getVarName())
public void ${column.getWriteMethod()}($dateSerializeType newVal){
#if($dateSerializeType == "Long")
${column.getSetMethod()}(null == newVal?null:new ${column.getJavaType()}(newVal));
#elseif($dateSerializeType == "String")
/** parse date time string to Date object */
${column.getSetMethod()}(gu.sql2java.Sql2javaSupport.parseDateString(newVal,${column.getJavaType()}.class));
#else
/** UNSUPPORTED dateSerializeType=$dateSerializeType */
#end
}
#elseif($column.isFloat())
#swiftThriftField2($column.getVarName())
#jacksonField($column.getVarName())
public void ${column.getWriteMethod()}(Double newVal){
${column.getSetMethod()}(null == newVal?null:newVal.floatValue());
}
#end
#end###if(($swiftBeanSupport || $jacksonBeanSupport ) && ($column.isDate() || $column.isFloat()))
#if ( $column.hasPrimaryType() )
#if($primitiveSetterSupport)
/**
* Setter method for {@link #$column.getVarName()}.
* Convenient for those who do not want to deal with Objects for primary types.
*
* @param newVal the new value to be assigned to $column.getVarName()
*/
#jacksonIgnore()
public void $column.getSetMethod()($column.getJavaPrimaryType() newVal)
{
$column.getSetMethod()(new $column.getJavaType()(newVal));
}
#end
#if($column.isDate() && $dateLongSetterSupport)
/**
* Setter method for {@link ${esc.hash}$column.getVarName()}.
* @param newVal the number of milliseconds since January 1, 1970, 00:00:00 GMT represented by this Date object.
*/
#jacksonIgnore()
public void $column.getSetMethod()(Long newVal)
{
$column.getSetMethod()(null == newVal ? null : new $column.getJavaType()(newVal));
}
#end
#end##if( $column.hasPrimaryType() )
/**
* Determines if the $column.getVarName() has been modified.
*
* @return true if the field has been modified, false if the field has not been modified
*/
public boolean ${column.getModifiedMethod()}()
{
return 0 != ${column.bitAndExpression("modified")};
}
/**
* Determines if the $column.getVarName() has been initialized.
*
* It is useful to determine if a field is null on purpose or just because it has not been initialized.
*
* @return true if the field has been initialized, false otherwise
*/
public boolean ${column.getInitializedMethod()}()
{
return 0 != ${column.bitAndExpression("initialized")};
}
#end
@Override
public boolean beModified()
{
#if( $table.stateVarTypeIsArray() )
for( ${codewriter.bitStateClassName} m: modified )if( 0 != m )return true;
return false;
#else
return 0 != modified;
#end
}
@Override
public boolean isModified(int columnID){
#if($table.countColumns()>32)
return columnID>=0 && columnID < metaData.columnCount && 0 != (modified[columnID/32] & (1 << (columnID%32)));
#else
return columnID>=0 && columnID < metaData.columnCount && 0 != (modified & (1 << columnID));
#end##($table.countColumns()>32)
}
@Override
public boolean isInitialized(int columnID){
#if($table.countColumns()>32)
return columnID>=0 && columnID < metaData.columnCount && 0 != (initialized[columnID/32] & (1 << (columnID%32)));
#else
return columnID>=0 && columnID < metaData.columnCount && 0 != (initialized & (1 << columnID));
#end##($table.countColumns()>32)
}
@Override
public void resetIsModified()
{
#if( $table.stateVarTypeIsArray() )
java.util.Arrays.fill(modified,0$!{codewriter.bitStateConstSuffix});
#else
modified = 0$!{codewriter.bitStateConstSuffix};
#end
}
@Override
public void resetModified(int mask){
modified &= (~(mask));
}
@Override
public void resetPrimaryKeysModified()
{
$table.bitResetAssignExpression($primaryKeys,"modified",' ');
}
/**
* Resets columns modification status except primary keys to 'not modified'.
*/
public void resetModifiedExceptPrimaryKeys()
{
$table.bitResetAssignExpression($table.getColumnsExceptPrimary(),"modified",' ');
}
/** reset all fields to initial value, equal to a new bean */
public void reset(){
#foreach($column in $columns)
#if($column.originalDefaultValue)
### Default value
$!{column.commentOfDefaultValue()}
#end
this.$column.getVarName()${column.getDefaultValueAssignment(true)};
#end
this.isNew = true;
this.modified = $table.maskInitializeWithZero();
this.initialized = $table.maskInitializeWithDefaultValue();
}
@Override
public $beanClass clone(){
return ($beanClass) super.clone();
}
################## NULL BEAN ###########
#if($table.stateVarTypeIsArray())
private static final boolean isAllZero(${codewriter.bitStateClassName}[] array){
for(${codewriter.bitStateClassName} e : array)if(0$!{codewriter.bitStateConstSuffix} != e)return false;
return true;
}
#end
############################################
public static final Builder builder(){
return new Builder().reset();
}
/**
* a builder for $beanClass,the template instance is thread local variable
* a instance of Builder can be reused.
*/
public static final class Builder{
/** $beanClass instance used for template to create new $beanClass instance. */
static final ThreadLocal<$beanClass> TEMPLATE = new ThreadLocal<$beanClass>(){
@Override
protected $beanClass initialValue() {
return new ${beanClass}();
}};
private Builder() {}
/**
* reset the bean as template
* @see ${beanClass}${esc.hash}reset()
*/
public Builder reset(){
TEMPLATE.get().reset();
return this;
}
/** set a bean as template,must not be {@code null} */
public Builder template($beanClass bean){
if(null == bean){
throw new NullPointerException();
}
TEMPLATE.set(bean);
return this;
}
/** return a clone instance of {@link ${esc.hash}TEMPLATE}*/
public $beanClass build(){
return TEMPLATE.get().clone();
}
#foreach($column in $columns)
/**
* fill the field : $column.fullName
* @param $column.varName $!{column.remarks}
* @see $beanClass${esc.hash}${column.getGetMethod()}()
* @see $beanClass${esc.hash}${column.getSetMethod()}($column.javaType)
*/
public Builder ${column.varName}($column.javaType $column.varName){
TEMPLATE.get().${column.getSetMethod()}($column.varName);
return this;
}
#end
}
####### FOR EXTENSION ##############
#parse( $codewriter.getProperty("template.extension.bean"))
}