class Lookup {
  final String? label;
  final String? key;
  final int? id;

  const Lookup({
    this.label,
    this.key,
    this.id,
  });

  @override
  bool operator ==(Object other) => identical(this, other) || other is Lookup && key == other.key && id == other.id;

  @override
  int get hashCode => id.hashCode;

  factory Lookup.fromStatus(Lookup old) {
    return Lookup(
      label: old.label,
      id: old.id,
      key: old.key,
    );
  }

  factory Lookup.fromJson(Map<String, dynamic> parsedJson) {
    return Lookup(
      label: parsedJson["value"],
      id: parsedJson["id"] is int? ? parsedJson["id"] : int.tryParse(parsedJson["id"] ?? parsedJson["uid"]),
    );
  }

  factory Lookup.fromIntIdJson(Map<String, dynamic> parsedJson) {
    return Lookup(
      label: parsedJson["value"],
      id: parsedJson["id"],
    );
  }
}
