valueCommands top-level property

List<Command> valueCommands
final

Implementation

final List<Command> valueCommands = [
  Command(
    prefix: '#',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      final subject = testSubject as String;
      self.type = subject.substring(1);
      self.explicitTypeOverride = true;
      return self;
    },
  ),
  Command(
    prefix: '\$',
    command: '[]',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      final subject = testSubject as String;
      final typeName = subject.substring(3).split('/').last.split('\\').last.toCamelCase();

      self.type = 'List<${typeName.toTitleCase()}>';
      self.isModel = true;
      return self;
    },
  ),
  Command(
    prefix: '\$',
    notprefix: '\$[]',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      final subject = testSubject as String;
      self.setName(key);

      final typeName = subject.substring(1).split('/').last.split('\\').last.toCamelCase();
      final type = typeName.toTitleCase();

      self.type = type;
      self.isModel = true;

      return self;
    },
  ),
  Command(
    prefix: '@',
    command: 'datetime',
    notprefix: '\$[]',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      self.setName(key);
      self.type = 'DateTime';
      return self;
    },
  ),
  Command(
    prefix: '@',
    command: 'timestamp',
    notprefix: '\$[]',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      self.setName(key);
      self.type = 'DateTime';
      return self;
    },
  ),
  Command(
    prefix: '@',
    command: 'enum',
    notprefix: '\$[]',
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      self.setEnumValues((value as String).substring('@enum:'.length).split(','));
      self.setName(key);
      return self;
    },
  ),
  Command(
    type: dynamic,
    callback: (DartDeclaration self, dynamic testSubject, {required String key, dynamic value}) {
      self.setName(key);

      if (value == null) {
        self.type = 'dynamic';
        return self;
      }
      if (value is Map) {
        self.type = key.toTitleCase();
        self.nestedClasses.add(JsonModel.fromMap('nested', value as Map<String, dynamic>));
        return self;
      }
      self.type = value.runtimeType.toString();
      return self;
    },
  ),
];