import 'dart:convert';

class TranslatorHistoryEntity {
  //翻译ID
  String? tid;
  //原文本
  String? sourceText;
  //原翻译国家编码
  String? sourcecountryCode;
  //原语言名称
  String? sourcelanguageName;
  //原语言编码
  String? sourcelanguageCode;
  //目标文本
  String? targetText;
  //目标翻译国家编码
  String? targetcountryCode;
  //目标语言名称
  String? targetlanguageName;
  //目标语言编码
  String? targetlanguageCode;
  //翻译时间
  String? translatorTime;
  //是否显示
  String? isShow;
  TranslatorHistoryEntity({
    this.tid,
    this.sourceText,
    this.sourcecountryCode,
    this.sourcelanguageName,
    this.sourcelanguageCode,
    this.targetText,
    this.targetcountryCode,
    this.targetlanguageName,
    this.targetlanguageCode,
    this.translatorTime,
    this.isShow,
  });

  TranslatorHistoryEntity copyWith({
    String? tid,
    String? sourceText,
    String? sourcecountryCode,
    String? sourcelanguageName,
    String? sourcelanguageCode,
    String? targetText,
    String? targetcountryCode,
    String? targetlanguageName,
    String? targetlanguageCode,
    String? translatorTime,
    String? isShow,
  }) {
    return TranslatorHistoryEntity(
      tid: tid ?? this.tid,
      sourceText: sourceText ?? this.sourceText,
      sourcecountryCode: sourcecountryCode ?? this.sourcecountryCode,
      sourcelanguageName: sourcelanguageName ?? this.sourcelanguageName,
      sourcelanguageCode: sourcelanguageCode ?? this.sourcelanguageCode,
      targetText: targetText ?? this.targetText,
      targetcountryCode: targetcountryCode ?? this.targetcountryCode,
      targetlanguageName: targetlanguageName ?? this.targetlanguageName,
      targetlanguageCode: targetlanguageCode ?? this.targetlanguageCode,
      translatorTime: translatorTime ?? this.translatorTime,
      isShow: isShow ?? this.isShow,
    );
  }

  Map<String, dynamic> toMap() {
    return <String, dynamic>{
      'tid': tid,
      'sourceText': sourceText,
      'sourcecountryCode': sourcecountryCode,
      'sourcelanguageName': sourcelanguageName,
      'sourcelanguageCode': sourcelanguageCode,
      'targetText': targetText,
      'targetcountryCode': targetcountryCode,
      'targetlanguageName': targetlanguageName,
      'targetlanguageCode': targetlanguageCode,
      'translatorTime': translatorTime,
      'isShow': isShow,
    };
  }

  factory TranslatorHistoryEntity.fromMap(Map<String, dynamic> map) {
    return TranslatorHistoryEntity(
      tid: map['tid'] != null ? map['tid'] as String : null,
      sourceText:
          map['sourceText'] != null ? map['sourceText'] as String : null,
      sourcecountryCode: map['sourcecountryCode'] != null
          ? map['sourcecountryCode'] as String
          : null,
      sourcelanguageName: map['sourcelanguageName'] != null
          ? map['sourcelanguageName'] as String
          : null,
      sourcelanguageCode: map['sourcelanguageCode'] != null
          ? map['sourcelanguageCode'] as String
          : null,
      targetText:
          map['targetText'] != null ? map['targetText'] as String : null,
      targetcountryCode: map['targetcountryCode'] != null
          ? map['targetcountryCode'] as String
          : null,
      targetlanguageName: map['targetlanguageName'] != null
          ? map['targetlanguageName'] as String
          : null,
      targetlanguageCode: map['targetlanguageCode'] != null
          ? map['targetlanguageCode'] as String
          : null,
      translatorTime: map['translatorTime'] != null
          ? map['translatorTime'] as String
          : null,
      isShow: map['isShow'] != null ? map['isShow'] as String : null,
    );
  }

  String toJson() => json.encode(toMap());

  factory TranslatorHistoryEntity.fromJson(String source) =>
      TranslatorHistoryEntity.fromMap(
          json.decode(source) as Map<String, dynamic>);

  @override
  String toString() {
    return 'TranslatorHistoryEntity(tid: $tid, sourceText: $sourceText, sourcecountryCode: $sourcecountryCode, sourcelanguageName: $sourcelanguageName, sourcelanguageCode: $sourcelanguageCode, targetText: $targetText, targetcountryCode: $targetcountryCode, targetlanguageName: $targetlanguageName, targetlanguageCode: $targetlanguageCode, translatorTime: $translatorTime, isShow: $isShow)';
  }

  @override
  bool operator ==(covariant TranslatorHistoryEntity other) {
    if (identical(this, other)) return true;

    return other.tid == tid &&
        other.sourceText == sourceText &&
        other.sourcecountryCode == sourcecountryCode &&
        other.sourcelanguageName == sourcelanguageName &&
        other.sourcelanguageCode == sourcelanguageCode &&
        other.targetText == targetText &&
        other.targetcountryCode == targetcountryCode &&
        other.targetlanguageName == targetlanguageName &&
        other.targetlanguageCode == targetlanguageCode &&
        other.translatorTime == translatorTime &&
        other.isShow == isShow;
  }

  @override
  int get hashCode {
    return tid.hashCode ^
        sourceText.hashCode ^
        sourcecountryCode.hashCode ^
        sourcelanguageName.hashCode ^
        sourcelanguageCode.hashCode ^
        targetText.hashCode ^
        targetcountryCode.hashCode ^
        targetlanguageName.hashCode ^
        targetlanguageCode.hashCode ^
        translatorTime.hashCode ^
        isShow.hashCode;
  }
}
