toJson method

  1. @override
Map<String, Object> toJson()
override

Returns a JSON representation of this entity.

Implementation

@override
Map<String,Object> toJson() {
  Map<String, Object> result = {};

  result['declaration'] = 'type';
  result['name'] = getName();
  result['runtimeType'] = getType().toString();
  result['isNullable'] = getIsNullable();
  result['kind'] = getKind().toString();

  final arguments = getTypeArguments().map((t) => t.toJson()).toList();
  if(arguments.isNotEmpty) {
    result['typeArguments'] = arguments;
  }

  final declaration = getDeclaration()?.toJson();
  if(declaration != null) {
    result['declaration'] = declaration;
  }

  final classType = asClass()?.toJson();
  if(classType != null) {
    result['asClassType'] = classType;
  }

  final enumType = asEnum()?.toJson();
  if(enumType != null) {
    result['asEnumType'] = enumType;
  }

  final typedefType = asTypedef()?.toJson();
  if(typedefType != null) {
    result['asTypedefType'] = typedefType;
  }

  final recordType = asRecord()?.toJson();
  if(recordType != null) {
    result['asRecordType'] = recordType;
  }

  final mixinType = asMixin()?.toJson();
  if(mixinType != null) {
    result['asMixinType'] = mixinType;
  }

  final typeVariable = asTypeVariable()?.toJson();
  if(typeVariable != null) {
    result['asTypeVariable'] = typeVariable;
  }
  return result;
}