Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let isAbstract = '';
if(classDeclaration.isAbstract() ) {
isAbstract = 'abstract ';
}
else {
isAbstract = '';
}
let superType = '';
if(classDeclaration.isSystemCoreType()) {
superType = ' extends org.hyperledger.composer.system.Resource';
}
if(classDeclaration.getSuperType()) {
superType = ' extends ' + ModelUtil.getShortName(classDeclaration.getSuperType());
}
this.plugin.addClassAnnotations(classDeclaration, parameters);
parameters.fileWriter.writeLine(0, 'public ' + isAbstract + 'class ' + classDeclaration.getName() + superType + ' {' );
// add the getID abstract type
if(classDeclaration.getIdentifierFieldName()) {
const getterName = 'get' + this.capitalizeFirstLetter(classDeclaration.getIdentifierFieldName());
parameters.fileWriter.writeLine(1, `
// the accessor for the identifying field
public String getID() {
return this.${getterName}();
}
`
);
}
visitClassDeclaration(classDeclaration, parameters) {
parameters.fileWriter.writeLine(0, 'type ' + classDeclaration.getName() + ' struct {' );
//embed the super-type, because Go Lang does not have 'extends'
if(classDeclaration.getSuperType()) {
parameters.fileWriter.writeLine(1, ModelUtil.getShortName(classDeclaration.getSuperType()));
}
classDeclaration.getOwnProperties().forEach((property) => {
property.accept(this,parameters);
});
parameters.fileWriter.writeLine(0, '}' );
return null;
}
visitClassDeclaration(classDeclaration, parameters) {
let isAbstract = '';
if (classDeclaration.isAbstract()) {
isAbstract = 'export abstract ';
} else {
isAbstract = 'export ';
}
let superType = '';
if (classDeclaration.getSuperType()) {
superType = ' extends ' + ModelUtil.getShortName(classDeclaration.getSuperType());
}
parameters.fileWriter.writeLine(1, isAbstract + 'class ' + classDeclaration.getName() + superType + ' {');
classDeclaration.getOwnProperties().forEach((property) => {
property.accept(this, parameters);
});
parameters.fileWriter.writeLine(1, '}');
return null;
}