You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
877 B
Dart
36 lines
877 B
Dart
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"],
|
|
);
|
|
}
|
|
}
|