ocHeader static method

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

Implementation

static String ocHeader(Model model, UniAPIOptions options) {
  return CodeTemplate(children: [
    CommentUniAPI(),
    EmptyLine(),
    OCImport(fullImportName: 'Foundation/Foundation.h'),
    OCCustomNestedImports(model.inputFile, options, fields: model.fields),
    EmptyLine(),
    OneLine(body: 'NS_ASSUME_NONNULL_BEGIN'),
    EmptyLine(),
    if (model.codeComments.isNotEmpty)
      Comment(
          comments: [...model.codeComments],
          commentType: CommentType.commentBlock),
    OCClassDeclaration(
        className: model.name,
        parentClass: 'NSObject', // use AST type fixme
        isInterface: true,
        properties: model.fields,
        classMethods: [
          Method(
              name: 'fromMap',
              returnType: AstCustomType(model.name),
              parameters: [Variable(AstMap(keyType: AstString()), 'dict')]),
          Method(
              name: 'modelList',
              returnType: AstList(generics: [AstCustomType(model.name)]),
              parameters: [
                Variable(AstList(generics: [AstMap()]), 'list')
              ]),
          Method(
              name: 'dicList',
              returnType: AstList(generics: [AstMap()]),
              parameters: [
                Variable(
                    AstList(generics: [AstCustomType(model.name)]), 'list')
              ])
        ],
        instanceMethods: [
          Method(name: 'toMap', returnType: AstMap(keyType: AstString()))
        ]),
    EmptyLine(),
    OneLine(body: 'NS_ASSUME_NONNULL_END'),
  ]).build();
}