import 'base.dart';

class Lookup extends Base {
  final int id, value;

  Lookup({this.id, this.value, String name}) : super(identifier: id?.toString(), name: name);

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

  @override
  int get hashCode => id?.hashCode ?? value?.hashCode;

  toJson() {
    return {"id": id, "name": name, "value": value};
  }

  factory Lookup.fromStatus(Lookup old) {
    if (old == null) return null;
    return Lookup(
      name: old.name,
      id: old.id,
      value: old.value,
    );
  }

  factory Lookup.fromJson(Map<String, dynamic> parsedJson) {
    if (parsedJson == null) return null;
    return Lookup(
      name: parsedJson["name"],
      id: parsedJson["id"],
      value: parsedJson["value"],
    );
  }
}
