in lib/generator.js [1810:1890]
apiBefore(extendParam, extendsClass, hasAPI, level) {
if (this.editable !== true) {
this.emit(`// This file is auto-generated, don't edit it. Thanks.\n`);
}
this.emit(`package ${this.package};
import com.aliyun.tea.*;
`);
if (hasAPI) {
this.emit('import com.aliyun.tea.interceptor.InterceptorChain;\n');
this.emit('import com.aliyun.tea.interceptor.RuntimeOptionsInterceptor;\n');
this.emit('import com.aliyun.tea.interceptor.RequestInterceptor;\n');
this.emit('import com.aliyun.tea.interceptor.ResponseInterceptor;\n');
}
if (extendParam.writeImport) {
this.emit(`import ${this.package}.models.*;\n`);
}
this.visitImport();
this.emit(`
public class ${this.className || 'Client'}`);
if (extendsClass) {
this.emit(` extends ${extendsClass.package + '.' + extendsClass.className}`);
}
if (this.implements) {
this.emit(` implements ${this.implements}`);
}
this.emit(` {\n`);
if (hasAPI) {
this.emit(`\n`);
this.emit('private final static InterceptorChain interceptorChain = InterceptorChain.create();\n', 1);
}
}
wrapBefore() {
this.emit(`\n`);
}
apiAfter(hasAPI, level) {
if (hasAPI) {
this.emit(`\n`);
this.emit('public void addRuntimeOptionsInterceptor(RuntimeOptionsInterceptor interceptor) {\n', level);
this.emit('interceptorChain.addRuntimeOptionsInterceptor(interceptor);\n', level + 1);
this.emit('}\n', level);
this.emit(`\n`);
this.emit('public void addRequestInterceptor(RequestInterceptor interceptor) {\n', level);
this.emit('interceptorChain.addRequestInterceptor(interceptor);\n', level + 1);
this.emit('}\n', level);
this.emit(`\n`);
this.emit('public void addResponseInterceptor(ResponseInterceptor interceptor) {\n', level);
this.emit('interceptorChain.addResponseInterceptor(interceptor);\n', level + 1);
this.emit('}\n', level);
}
}
typeRelover(type, module) {
if (module && module.idType === 'module') {
const aliasId = _name(module);
if (this.imports[aliasId] && this.imports[aliasId].typedef && this.imports[aliasId].typedef[type.lexeme]) {
let reslut = this.imports[aliasId].typedef[type.lexeme].import;
if (this.imports[aliasId].typedef[type.lexeme].type) {
reslut = `${reslut}.${this.imports[aliasId].typedef[type.lexeme].type}`;
}
return reslut;
}
}
if (type.idType === 'typedef' && this.typedef[type.lexeme]) {
let reslut = this.typedef[type.lexeme].import;
if (this.typedef[type.lexeme].type) {
reslut = `${reslut}.${this.typedef[type.lexeme].type}`;
}
return reslut;
}
return _type(type);
}
}