/// Created by Haoyi on 2023/2/15

class GuruStatistic {

  static const loggedField = "logged";
  static const uploadedField = "uploaded";

  final int logged;
  final int uploaded;

  const GuruStatistic({required this.logged, required this.uploaded});

  static const GuruStatistic invalid = GuruStatistic(logged: 0, uploaded: 0);

  factory GuruStatistic.fromJson(Map<dynamic, dynamic> json) =>
      GuruStatistic(
        logged: json[loggedField] as int? ?? 0,
        uploaded: json[uploadedField] as int? ?? 0,
      );

  Map<String, dynamic> toJson(GuruStatistic instance) =>
      <String, dynamic>{
        loggedField: instance.logged,
        uploadedField: instance.uploaded
      };

  @override
  bool operator ==(Object other) =>
      identical(this, other) ||
          other is GuruStatistic && runtimeType == other.runtimeType && logged == other.logged &&
              uploaded == other.uploaded;

  @override
  int get hashCode => logged.hashCode ^ uploaded.hashCode;

  @override
  String toString() {
    return 'GuruStatistic{logged: $logged, uploaded: $uploaded}';
  }
}