Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.map((line, index) => {
const isLast = lines.length === index + 1;
const isFirst = index === 0;
if (isFirst && isLast) {
return indent(`// ${comment} \n`, indentLevel);
}
line = line.split('*/').join('*\\/');
return indent(`${isFirst ? '/*' : ''} * ${line}${isLast ? '\n */\n' : ''}`, indentLevel);
})
.join('\n');
.map((line, index) => {
const isLast = lines.length === index + 1;
const isFirst = index === 0;
if (isFirst && isLast) {
return indent(`// ${comment} */\n`, indentLevel);
}
return indent(`${isFirst ? '/*' : ''} * ${line}${isLast ? '\n */\n' : ''}`, indentLevel);
})
.join('\n');
.map(arg => {
const typeToUse = this.resolveInputFieldType(arg.type);
if (typeToUse.isArray && !typeToUse.isScalar) {
this._addListImport = true;
return indent(`this._${arg.name.value} = ((List>) args.get("${arg.name.value}")).stream().map(${typeToUse.baseType}::new).collect(Collectors.toList());`, 3);
} else if (typeToUse.isScalar) {
return indent(`this._${arg.name.value} = (${typeToUse.typeName}) args.get("${arg.name.value}");`, 3);
} else {
return indent(`this._${arg.name.value} = new ${typeToUse.typeName}((Map) args.get("${arg.name.value}"));`, 3);
}
})
.join('\n');
const interfaces = nonIdFields.map((field, idx) => {
const fieldName = this.getFieldName(field);
const isLastField = nonIdFields.length - 1 === idx ? true : false;
const returnType = isLastField ? 'Build' : nonIdFields[idx + 1].name;
const interfaceName = this.getStepInterfaceName(field.name);
const interfaceDeclaration = new JavaDeclarationBlock()
.asKind('interface')
.withName(interfaceName)
.access('public');
interfaceDeclaration.withBlock(
indent(`${this.getStepInterfaceName(returnType)} ${fieldName}(${this.getNativeType(field)} ${fieldName});`)
);
return interfaceDeclaration;
});
@Override
public void write(Object value, ResponseWriter.ListItemWriter listItemWriter) {
listItemWriter.${writerMethod.name}(((${f.className}) value)${writerMethod.useMarshaller ? '.marshaller()' : ''});
}
});`,
2
);
}
let fValue = `${f.fieldName}${writerMethod.useMarshaller ? '.marshaller()' : ''}`;
if (writerMethod.checkNull || !f.isNonNull) {
fValue = `${f.fieldName} != null ? ${fValue} : null`;
}
return indent(`writer.${writerMethod.name}(${writerMethod.castTo ? `(${writerMethod.castTo}) ` : ''}$responseFields[${index}], ${fValue});`, 2);
})
.join('\n')}
const fields = Object.keys(root).map(fieldName => {
const fieldValue = root[fieldName];
return indent(`${fieldName}: ${this._getInnerField(fieldValue, level + 1)},`, level);
});
.map(m => (this.config.noNamespaces ? m : indent(m)))
.join('\n');
FieldDefinition(node: FieldDefinitionNode, key?: number | string, parent?: any): string {
const typeString = (node.type as any) as string;
const originalFieldNode = parent[key] as FieldDefinitionNode;
const addOptionalSign = !this.config.avoidOptionals.object && originalFieldNode.type.kind !== Kind.NON_NULL_TYPE;
const comment = transformComment((node.description as any) as string, 1);
return comment + indent(`${this.config.immutableTypes ? 'readonly ' : ''}${node.name}${addOptionalSign ? '?' : ''}: ${typeString},`);
}
model.fields.forEach((field: CodeGenField) => {
const fieldName = this.getFieldName(field);
const returnType = this.getNativeType(field);
const methodName = `get${pascalCase(field.name)}`;
const body = indent(`return ${fieldName};`);
declarationsBlock.addClassMethod(methodName, returnType, body, undefined, undefined, 'public');
});
}
const interfaces = requiredInterfaces.map((field, idx) => {
const isLastField = requiredInterfaces.length - 1 === idx ? true : false;
const returnType = isLastField ? 'Build' : requiredInterfaces[idx + 1].name;
const interfaceName = this.getStepInterfaceName(field.name);
const methodName = this.getStepFunctionName(field);
const argumentType = this.getNativeType(field);
const argumentName = this.getStepFunctionArgumentName(field);
const interfaceDeclaration = new JavaDeclarationBlock()
.asKind('interface')
.withName(interfaceName)
.access('public');
interfaceDeclaration.withBlock(indent(`${this.getStepInterfaceName(returnType)} ${methodName}(${argumentType} ${argumentName});`));
return interfaceDeclaration;
});