stack_wallet/lib/models/isar/exchange_cache/pair.dart

74 lines
1.3 KiB
Dart
Raw Normal View History

2023-05-26 21:21:16 +00:00
/*
* This file is part of Stack Wallet.
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
* Generated by Cypher Stack on 2023-05-26
*
*/
import 'package:isar/isar.dart';
2022-10-03 15:41:53 +00:00
part 'pair.g.dart';
2023-02-06 14:43:16 +00:00
// embedded enum // no not modify
enum SupportedRateType { fixed, estimated, both }
@collection
2022-10-02 19:37:11 +00:00
class Pair {
2023-02-06 14:43:16 +00:00
Pair({
required this.exchangeName,
required this.from,
required this.to,
required this.rateType,
});
Id? id;
@Index()
final String exchangeName;
2024-05-27 23:56:22 +00:00
@Index(
composite: [
CompositeIndex("exchangeName"),
CompositeIndex("to"),
],
)
2022-10-02 19:37:11 +00:00
final String from;
final String to;
2023-02-06 14:43:16 +00:00
@enumerated
final SupportedRateType rateType;
2022-10-03 15:41:53 +00:00
Map<String, dynamic> toMap() {
2022-10-02 19:37:11 +00:00
return {
"id": id,
"exchangeName": exchangeName,
2022-10-02 19:37:11 +00:00
"from": from,
"to": to,
2023-02-06 14:43:16 +00:00
"rateType": rateType,
2022-10-02 19:37:11 +00:00
};
}
@override
2022-10-03 15:41:53 +00:00
bool operator ==(other) =>
other is Pair &&
exchangeName == other.exchangeName &&
2022-10-03 15:41:53 +00:00
from == other.from &&
to == other.to &&
2023-02-06 14:43:16 +00:00
rateType == other.rateType;
2022-10-03 15:41:53 +00:00
@override
int get hashCode => Object.hash(
exchangeName,
2022-10-03 15:41:53 +00:00
from,
to,
2023-02-06 14:43:16 +00:00
rateType,
2022-10-03 15:41:53 +00:00
);
@override
String toString() => "Pair: ${toMap()}";
2022-10-02 19:37:11 +00:00
}