getEntityClass method
Implementation
String getEntityClass(String suffix, String name, String parent, Map? map,
[bool root = false]) {
if (map == null) return '';
final apiClassName = ModelClassNameHelper.getClassName(
listClassNameEntity, suffix, name, root, true, parent);
final classString = '''class $apiClassName extends Equatable {
${setConstractor(apiClassName, map)}
${setTypeData(map, suffix, listClassNameEntity, apiClassName)}
$apiClassName copyWith({
${map.keys.map((e) => '${getTypeVariable(e, map[e], suffix, listClassNameEntity, apiClassName)}? ${e.toString().camelCase},').join('\n ')}
}) {
return $apiClassName(
${map.keys.map((e) => '${e.toString().camelCase}: ${e.toString().camelCase} ?? this.${e.toString().camelCase},').join('\n ')}
);
}
${setPropsEquatable(map)}
}
${map.keys.map((e) => map[e] is Map ? getEntityClass(suffix, e.toString().pascalCase, apiClassName, map[e]) : '').join()}
${map.keys.map((e) => map[e] is List ? map[e] == null ? '' : (map[e] as List).isEmpty ? '' : (map[e] as List).first is! Map ? '' : getEntityClass(suffix, e.toString().pascalCase, apiClassName, (map[e] as List).first) : '').join()}
''';
return classString;
}