108 lines
3.6 KiB
Plaintext
108 lines
3.6 KiB
Plaintext
## --------------------------------------------------
|
|
#if ( !($entity.hasTag("BaseModel"))) )
|
|
#cancel("Not a Base Model")
|
|
#end
|
|
## --------------------------------------------------
|
|
/*
|
|
* Java generated command response class for entity "${entity.name}"
|
|
* Created on $now.date ( $now.time )
|
|
* Generated by $generator.name ( version $generator.version )
|
|
*/
|
|
package ${target.javaPackageFromFolder("${component}/${SRC}")};
|
|
|
|
import java.io.Serializable;
|
|
|
|
/**
|
|
* Generated command response class for entity "${entity.name}"
|
|
*
|
|
* @author Telosys Tools Generator
|
|
*
|
|
*/
|
|
@lombok.EqualsAndHashCode(callSuper=true)
|
|
public class Command${commandType}${entity.name}Response extends Command implements Serializable {
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
#if ( ${commandType} == "List" )
|
|
private java.util.List<${entity.name}> entities;
|
|
#end
|
|
#if ( ${commandType} == "Get" || ${commandType} == "Create" || ${commandType} == "Update" || ${commandType} == "Delete" )
|
|
private ${entity.name} entity;
|
|
#end
|
|
|
|
//----------------------------------------------------------------------
|
|
// CONSTRUCTOR(S)
|
|
//----------------------------------------------------------------------
|
|
public Command${commandType}${entity.name}Response() {
|
|
super();
|
|
}
|
|
|
|
#if ( ${commandType} == "List" )
|
|
public Command${commandType}${entity.name}Response(java.util.List<${entity.name}> entities) {
|
|
this();
|
|
this.entities = entities;
|
|
}
|
|
|
|
public void setList(java.util.List<${entity.name}> entities) {
|
|
this.entities = entities;
|
|
}
|
|
|
|
public java.util.List<${entity.name}> getList() {
|
|
return this.entities;
|
|
}
|
|
#end
|
|
#if ( ${commandType} == "Get" || ${commandType} == "Create" || ${commandType} == "Update" || ${commandType} == "Delete" )
|
|
public Command${commandType}${entity.name}Response(${entity.name} entity) {
|
|
this();
|
|
this.entity = entity;
|
|
}
|
|
|
|
public void set${entity.name}(${entity.name} entity) {
|
|
this.entity = entity;
|
|
}
|
|
|
|
public ${entity.name} get${entity.name}() {
|
|
return this.entity;
|
|
}
|
|
#end
|
|
|
|
public CommandWrapper serialize() throws java.io.IOException {
|
|
CommandWrapper wrapper = new CommandWrapper();
|
|
wrapper.setType(Command${commandType}${entity.name}Response.class.getSimpleName());
|
|
wrapper.setPayload(OBJECT_MAPPER.writeValueAsBytes(this));
|
|
return wrapper;
|
|
}
|
|
|
|
public static Command${commandType}${entity.name}Response deserialize(CommandWrapper wrapper) throws java.io.IOException {
|
|
return OBJECT_MAPPER.readValue(wrapper.getPayload(), Command${commandType}${entity.name}Response.class);
|
|
}
|
|
|
|
public static boolean isType(CommandWrapper wrapper) {
|
|
return wrapper.getType().equals(Command${commandType}${entity.name}Response.class.getSimpleName());
|
|
}
|
|
|
|
#if ( $component == "persistence" )
|
|
@Override
|
|
public Command process() throws Exception {
|
|
throw new UnsupportedOperationException();
|
|
}
|
|
#end
|
|
|
|
//----------------------------------------------------------------------
|
|
// toString METHOD
|
|
//----------------------------------------------------------------------
|
|
public String toString() {
|
|
String separator = "|";
|
|
StringBuilder sb = new StringBuilder();
|
|
sb.append("${entity.name}[");
|
|
#if ( ${commandType} == "List" )
|
|
sb.append("entities=").append(this.entities);
|
|
#end
|
|
#if ( ${commandType} == "Get" || ${commandType} == "Create" || ${commandType} == "Update" || ${commandType} == "Delete" )
|
|
sb.append("entity=").append(this.entity);
|
|
#end
|
|
sb.append("]");
|
|
return sb.toString();
|
|
}
|
|
}
|