javaCode static method

String javaCode(
  1. Model model,
  2. UniAPIOptions options
)

Implementation

static String javaCode(Model model, UniAPIOptions options) {
  return CodeTemplate(children: [
    CommentUniAPI(),
    EmptyLine(),
    JavaPackage(model.inputFile, options),
    EmptyLine(),
    JavaImport(fullClassName: 'java.util.List'),
    JavaImport(fullClassName: 'java.util.Map'),
    JavaImport(fullClassName: 'java.util.HashMap'),
    JavaImport(fullClassName: 'java.util.ArrayList'),
    JavaImport(
        fullClassName:
            '${options.javaPackageName}.$projectName.$uniModelAnnotation'),
    JavaCustomNestedImports(model.inputFile, options, fields: model.fields),
    EmptyLine(),
    if (model.codeComments.isNotEmpty)
      Comment(
          comments: [...model.codeComments],
          commentType: CommentType.commentBlock),
    JavaClass(
        className: model.name,
        parentClass: uniModelAnnotation,
        isPublic: true,
        privateFields: model.fields,
        fieldGettersAndSetters: model.fields,
        hasFromMap: true,
        injectedJavaCodes: (depth) => [
              ...JavaCollectionCloneFunction()
                  .handlerJavaCollectionType(fields: model.fields),
            ],
        hasToMap: true)
  ]).build();
}