From 9ce5ade33987391c2f829b630ee4cff58c3ab925 Mon Sep 17 00:00:00 2001 From: Edouard Marquez Date: Mon, 11 Dec 2023 15:15:51 +0100 Subject: [PATCH] CopyWith methods for all classes --- lib/src/model/additives.dart | 10 ++ lib/src/model/agribalyse.dart | 8 + lib/src/model/allergens.dart | 10 ++ lib/src/model/attribute.dart | 30 ++++ lib/src/model/attribute_group.dart | 15 ++ lib/src/model/badge_base.dart | 12 ++ lib/src/model/ecoscore_adjustments.dart | 10 ++ lib/src/model/ecoscore_data.dart | 18 +++ lib/src/model/events_base.dart | 16 ++ lib/src/model/ingredient.dart | 26 ++++ lib/src/model/insight.dart | 30 ++++ lib/src/model/key_stats.dart | 12 ++ lib/src/model/knowledge_panel.dart | 39 +++++ lib/src/model/knowledge_panel_element.dart | 162 ++++++++++++++++++++ lib/src/model/leaderboard_entry.dart | 10 ++ lib/src/model/login_status.dart | 16 ++ lib/src/model/ocr_ingredients_result.dart | 14 ++ lib/src/model/ocr_packaging_result.dart | 12 ++ lib/src/model/product.dart | 161 +++++++++++++++++++ lib/src/model/product_freshness.dart | 16 ++ lib/src/model/product_image.dart | 34 ++++ lib/src/model/product_list.dart | 12 ++ lib/src/model/product_stats.dart | 14 ++ lib/src/model/product_tag.dart | 22 +++ lib/src/model/recommended_daily_intake.dart | 76 +++++++++ lib/src/model/robotoff_question.dart | 30 ++++ lib/src/model/search_result.dart | 18 +++ lib/src/model/send_image.dart | 14 ++ lib/src/model/spelling_corrections.dart | 26 ++++ lib/src/model/status.dart | 1 + lib/src/model/taxonomy_additive.dart | 73 +++++++++ lib/src/model/taxonomy_allergen.dart | 12 ++ lib/src/model/taxonomy_category.dart | 65 ++++++++ lib/src/model/taxonomy_ingredient.dart | 99 ++++++++++++ lib/src/model/taxonomy_label.dart | 54 +++++++ lib/src/model/taxonomy_language.dart | 14 ++ lib/src/model/taxonomy_packaging_shape.dart | 2 + lib/src/model/user.dart | 12 ++ lib/src/model/user_agent.dart | 16 ++ 39 files changed, 1221 insertions(+) diff --git a/lib/src/model/additives.dart b/lib/src/model/additives.dart index 81e1d2a3f0..5feeea8872 100644 --- a/lib/src/model/additives.dart +++ b/lib/src/model/additives.dart @@ -35,4 +35,14 @@ class Additives { return result; } + + Additives copyWith({ + List? ids, + List? names, + }) { + return Additives( + ids ?? this.ids, + names ?? this.names, + ); + } } diff --git a/lib/src/model/agribalyse.dart b/lib/src/model/agribalyse.dart index 5489614ddc..7964a814b8 100644 --- a/lib/src/model/agribalyse.dart +++ b/lib/src/model/agribalyse.dart @@ -15,4 +15,12 @@ class Agribalyse extends JsonObject { @override Map toJson() => _$AgribalyseToJson(this); + + Agribalyse copyWith({ + double? score, + }) { + return Agribalyse( + score: score ?? this.score, + ); + } } diff --git a/lib/src/model/allergens.dart b/lib/src/model/allergens.dart index f500b9804e..fc0dbfa0c5 100644 --- a/lib/src/model/allergens.dart +++ b/lib/src/model/allergens.dart @@ -68,4 +68,14 @@ class Allergens { return result; } + + Allergens copyWith({ + List? ids, + List? names, + }) { + return Allergens( + ids ?? this.ids, + names ?? this.names, + ); + } } diff --git a/lib/src/model/attribute.dart b/lib/src/model/attribute.dart index 523e9d8042..ed75f405d9 100644 --- a/lib/src/model/attribute.dart +++ b/lib/src/model/attribute.dart @@ -115,4 +115,34 @@ class Attribute extends JsonObject { @override String toString() => 'Attribute(${toJson()})'; + + Attribute copyWith({ + String? id, + String? name, + String? title, + String? iconUrl, + String? defaultF, + String? settingNote, + String? settingName, + String? description, + String? descriptionShort, + double? match, + String? status, + String? panelId, + }) { + return Attribute( + id: id ?? this.id, + name: name ?? this.name, + title: title ?? this.title, + iconUrl: iconUrl ?? this.iconUrl, + defaultF: defaultF ?? this.defaultF, + settingNote: settingNote ?? this.settingNote, + settingName: settingName ?? this.settingName, + description: description ?? this.description, + descriptionShort: descriptionShort ?? this.descriptionShort, + match: match ?? this.match, + status: status ?? this.status, + panelId: panelId ?? this.panelId, + ); + } } diff --git a/lib/src/model/attribute_group.dart b/lib/src/model/attribute_group.dart index ce2ebdcc5b..307e12f5f6 100644 --- a/lib/src/model/attribute_group.dart +++ b/lib/src/model/attribute_group.dart @@ -50,6 +50,21 @@ class AttributeGroup extends JsonObject { return result; } + + AttributeGroup copyWith({ + String? id, + String? name, + String? warning, + List? attributes, + }) { + return AttributeGroup( + id: id ?? this.id, + name: name ?? this.name, + warning: warning ?? this.warning, + attributes: attributes ?? this.attributes, + ); + } + static const String ATTRIBUTE_GROUP_NUTRITIONAL_QUALITY = 'nutritional_quality'; static const String ATTRIBUTE_GROUP_PROCESSING = 'processing'; diff --git a/lib/src/model/badge_base.dart b/lib/src/model/badge_base.dart index ee16936c6f..7530a51d24 100644 --- a/lib/src/model/badge_base.dart +++ b/lib/src/model/badge_base.dart @@ -32,4 +32,16 @@ class BadgeBase extends JsonObject { ', level: $level' '${userId == null ? '' : ', userId: $userId'}' ')'; + + BadgeBase copyWith({ + String? userId, + String? badgeName, + int? level, + }) { + return BadgeBase( + userId: userId ?? this.userId, + badgeName: badgeName ?? this.badgeName, + level: level ?? this.level, + ); + } } diff --git a/lib/src/model/ecoscore_adjustments.dart b/lib/src/model/ecoscore_adjustments.dart index 96c8e9e927..113bdd9a33 100644 --- a/lib/src/model/ecoscore_adjustments.dart +++ b/lib/src/model/ecoscore_adjustments.dart @@ -19,4 +19,14 @@ class EcoscoreAdjustments extends JsonObject { @override Map toJson() => _$EcoscoreAdjustmentsToJson(this); + + EcoscoreAdjustments copyWith({ + Packaging? packaging, + OriginsOfIngredients? originsOfIngredients, + }) { + return EcoscoreAdjustments( + packaging: packaging ?? this.packaging, + originsOfIngredients: originsOfIngredients ?? this.originsOfIngredients, + ); + } } diff --git a/lib/src/model/ecoscore_data.dart b/lib/src/model/ecoscore_data.dart index cc673f31bf..ea001ac031 100644 --- a/lib/src/model/ecoscore_data.dart +++ b/lib/src/model/ecoscore_data.dart @@ -46,4 +46,22 @@ class EcoscoreData extends JsonObject { Map toJson() => _$EcoscoreDataToJson(this); static Map? toJsonHelper(EcoscoreData? d) => d?.toJson(); + + EcoscoreData copyWith({ + String? grade, + double? score, + EcoscoreStatus? status, + Agribalyse? agribalyse, + EcoscoreAdjustments? adjustments, + bool? missingDataWarning, + }) { + return EcoscoreData( + grade: grade ?? this.grade, + score: score ?? this.score, + status: status ?? this.status, + agribalyse: agribalyse ?? this.agribalyse, + adjustments: adjustments ?? this.adjustments, + missingDataWarning: missingDataWarning ?? this.missingDataWarning, + ); + } } diff --git a/lib/src/model/events_base.dart b/lib/src/model/events_base.dart index 5b37bc1265..920ab9548d 100644 --- a/lib/src/model/events_base.dart +++ b/lib/src/model/events_base.dart @@ -43,4 +43,20 @@ class EventsBase extends JsonObject { '${barcode == null ? '' : ', barcode: $barcode'}' '${points == null ? '' : ', points: $points'}' ')'; + + EventsBase copyWith({ + String? eventType, + DateTime? timestamp, + String? userId, + String? barcode, + int? points, + }) { + return EventsBase( + eventType: eventType ?? this.eventType, + timestamp: timestamp ?? this.timestamp, + userId: userId ?? this.userId, + barcode: barcode ?? this.barcode, + points: points ?? this.points, + ); + } } diff --git a/lib/src/model/ingredient.dart b/lib/src/model/ingredient.dart index 58ded6111d..4f9b7ce037 100644 --- a/lib/src/model/ingredient.dart +++ b/lib/src/model/ingredient.dart @@ -84,6 +84,32 @@ class Ingredient extends JsonObject { '${bold == null ? '' : ',bold=$bold'}' '${ingredients == null ? '' : ',ingredients=$ingredients'}' ')'; + + Ingredient copyWith({ + int? rank, + String? id, + String? text, + double? percent, + double? percentEstimate, + IngredientSpecialPropertyStatus? vegan, + IngredientSpecialPropertyStatus? vegetarian, + IngredientSpecialPropertyStatus? fromPalmOil, + List? ingredients, + bool? bold, + }) { + return Ingredient( + rank: rank ?? this.rank, + id: id ?? this.id, + text: text ?? this.text, + percent: percent ?? this.percent, + percentEstimate: percentEstimate ?? this.percentEstimate, + vegan: vegan ?? this.vegan, + vegetarian: vegetarian ?? this.vegetarian, + fromPalmOil: fromPalmOil ?? this.fromPalmOil, + ingredients: ingredients ?? this.ingredients, + bold: bold ?? this.bold, + ); + } } const Map _MAP = { diff --git a/lib/src/model/insight.dart b/lib/src/model/insight.dart index 2142ef8dcc..6f469e8a15 100644 --- a/lib/src/model/insight.dart +++ b/lib/src/model/insight.dart @@ -75,6 +75,16 @@ class InsightsResult extends JsonObject { @override Map toJson() => _$InsightsResultToJson(this); + + InsightsResult copyWith({ + String? status, + List? insights, + }) { + return InsightsResult( + status: status ?? this.status, + insights: insights ?? this.insights, + ); + } } class Insight { @@ -137,4 +147,24 @@ class Insight { return result; } + + Insight copyWith({ + String? id, + InsightType? type, + String? barcode, + List? countries, + String? lang, + String? model, + double? confidence, + }) { + return Insight( + id: id ?? this.id, + type: type ?? this.type, + barcode: barcode ?? this.barcode, + countries: countries ?? this.countries, + lang: lang ?? this.lang, + model: model ?? this.model, + confidence: confidence ?? this.confidence, + ); + } } diff --git a/lib/src/model/key_stats.dart b/lib/src/model/key_stats.dart index b63e2e401e..e67ac55aa3 100644 --- a/lib/src/model/key_stats.dart +++ b/lib/src/model/key_stats.dart @@ -27,4 +27,16 @@ class KeyStats extends JsonObject { @override String toString() => toJson().toString(); + + KeyStats copyWith({ + String? key, + int? count, + int? values, + }) { + return KeyStats( + key: key ?? this.key, + count: count ?? this.count, + values: values ?? this.values, + ); + } } diff --git a/lib/src/model/knowledge_panel.dart b/lib/src/model/knowledge_panel.dart index 27e31da1f9..cfe2a37492 100644 --- a/lib/src/model/knowledge_panel.dart +++ b/lib/src/model/knowledge_panel.dart @@ -120,6 +120,26 @@ class KnowledgePanel extends JsonObject { @override Map toJson() => _$KnowledgePanelToJson(this); + + KnowledgePanel copyWith({ + TitleElement? titleElement, + Level? level, + bool? expanded, + List? elements, + List? topics, + final Evaluation? evaluation, + final KnowledgePanelSize? size, + }) { + return KnowledgePanel( + titleElement: titleElement ?? this.titleElement, + level: level ?? this.level, + expanded: expanded ?? this.expanded, + elements: elements ?? this.elements, + topics: topics ?? this.topics, + evaluation: evaluation ?? this.evaluation, + size: size ?? this.size, + ); + } } /// An element representing the title of the KnowledgePanel which could consist @@ -167,4 +187,23 @@ class TitleElement extends JsonObject { @override Map toJson() => _$TitleElementToJson(this); + + TitleElement copyWith({ + String? title, + String? subtitle, + final Grade? grade, + final TitleElementType? type, + final String? iconUrl, + final bool? iconColorFromEvaluation, + }) { + return TitleElement( + title: title ?? this.title, + subtitle: subtitle ?? this.subtitle, + grade: grade ?? this.grade, + type: type ?? this.type, + iconUrl: iconUrl ?? this.iconUrl, + iconColorFromEvaluation: + iconColorFromEvaluation ?? this.iconColorFromEvaluation, + ); + } } diff --git a/lib/src/model/knowledge_panel_element.dart b/lib/src/model/knowledge_panel_element.dart index a387cfc1d7..527fc79ce3 100644 --- a/lib/src/model/knowledge_panel_element.dart +++ b/lib/src/model/knowledge_panel_element.dart @@ -74,6 +74,24 @@ class KnowledgePanelTextElement extends JsonObject { @override Map toJson() => _$KnowledgePanelTextElementToJson(this); + + KnowledgePanelTextElement copyWith({ + String? html, + KnowledgePanelTextElementType? type, + String? sourceLanguage, + String? sourceLocale, + String? sourceText, + String? sourceUrl, + }) { + return KnowledgePanelTextElement( + html: html ?? this.html, + type: type ?? this.type, + sourceLanguage: sourceLanguage ?? this.sourceLanguage, + sourceLocale: sourceLocale ?? this.sourceLocale, + sourceText: sourceText ?? this.sourceText, + sourceUrl: sourceUrl ?? this.sourceUrl, + ); + } } /// Image that represents the KnowledgePanel. @@ -106,6 +124,20 @@ class KnowledgePanelImageElement extends JsonObject { @override Map toJson() => _$KnowledgePanelImageElementToJson(this); + + KnowledgePanelImageElement copyWith({ + String? url, + int? width, + int? height, + String? altText, + }) { + return KnowledgePanelImageElement( + url: url ?? this.url, + width: width ?? this.width, + height: height ?? this.height, + altText: altText ?? this.altText, + ); + } } /// Element representing a Panel group that contains 1+ KnowledgePanels. @@ -127,6 +159,16 @@ class KnowledgePanelPanelGroupElement extends JsonObject { @override Map toJson() => _$KnowledgePanelPanelGroupElementToJson(this); + + KnowledgePanelPanelGroupElement copyWith({ + String? title, + List? panelIds, + }) { + return KnowledgePanelPanelGroupElement( + title: title ?? this.title, + panelIds: panelIds ?? this.panelIds, + ); + } } /// Element representing a Panel Id of a KnowledgePanel. This element is a @@ -144,6 +186,14 @@ class KnowledgePanelPanelIdElement extends JsonObject { @override Map toJson() => _$KnowledgePanelPanelIdElementToJson(this); + + KnowledgePanelPanelIdElement copyWith({ + String? panelId, + }) { + return KnowledgePanelPanelIdElement( + panelId: panelId ?? this.panelId, + ); + } } /// Provides the values for each table cell inside a KnowledgePanel table. @@ -168,6 +218,20 @@ class KnowledgePanelTableCell extends JsonObject { @override Map toJson() => _$KnowledgePanelTableCellToJson(this); + + KnowledgePanelTableCell copyWith({ + String? text, + double? percent, + String? iconUrl, + Evaluation? evaluation, + }) { + return KnowledgePanelTableCell( + text: text ?? this.text, + percent: percent ?? this.percent, + iconUrl: iconUrl ?? this.iconUrl, + evaluation: evaluation ?? this.evaluation, + ); + } } /// A table row inside Table element of KonwledgePanel @@ -182,6 +246,14 @@ class KnowledgePanelTableRowElement extends JsonObject { @override Map toJson() => _$KnowledgePanelTableRowElementToJson(this); + + KnowledgePanelTableRowElement copyWith({ + List? values, + }) { + return KnowledgePanelTableRowElement( + values: values ?? this.values, + ); + } } /// A descriptor that describes the type and label of each column. @@ -217,6 +289,24 @@ class KnowledgePanelTableColumn extends JsonObject { @override Map toJson() => _$KnowledgePanelTableColumnToJson(this); + + KnowledgePanelTableColumn copyWith({ + String? text, + String? textForSmallScreens, + bool? showByDefault, + String? columnGroupId, + final String? style, + final KnowledgePanelColumnType? type, + }) { + return KnowledgePanelTableColumn( + text: text ?? this.text, + textForSmallScreens: textForSmallScreens ?? this.textForSmallScreens, + showByDefault: showByDefault ?? this.showByDefault, + columnGroupId: columnGroupId ?? this.columnGroupId, + style: style ?? this.style, + type: type ?? this.type, + ); + } } /// Element representing a world map. @@ -233,6 +323,14 @@ class KnowledgePanelWorldMapElement extends JsonObject { @override Map toJson() => _$KnowledgePanelWorldMapElementToJson(this); + + KnowledgePanelWorldMapElement copyWith({ + List? pointers, + }) { + return KnowledgePanelWorldMapElement( + pointers: pointers ?? this.pointers, + ); + } } /// Element representing a geo location of a map pointer. @@ -249,6 +347,14 @@ class KnowledgePanelGeoPointer extends JsonObject { @override Map toJson() => _$KnowledgePanelGeoPointerToJson(this); + + KnowledgePanelGeoPointer copyWith({ + KnowledgePanelLatLng? geo, + }) { + return KnowledgePanelGeoPointer( + geo: geo ?? this.geo, + ); + } } /// Element representing a lat/long positioning of a map pointer. @@ -267,6 +373,16 @@ class KnowledgePanelLatLng extends JsonObject { @override Map toJson() => _$KnowledgePanelLatLngToJson(this); + + KnowledgePanelLatLng copyWith({ + double? lat, + double? lng, + }) { + return KnowledgePanelLatLng( + lat: lat ?? this.lat, + lng: lng ?? this.lng, + ); + } } /// Element representing a tabular data for the KnowledgePanel. @@ -293,6 +409,20 @@ class KnowledgePanelTableElement extends JsonObject { @override Map toJson() => _$KnowledgePanelTableElementToJson(this); + + KnowledgePanelTableElement copyWith({ + String? id, + String? title, + List? columns, + List? rows, + }) { + return KnowledgePanelTableElement( + id: id ?? this.id, + title: title ?? this.title, + columns: columns ?? this.columns, + rows: rows ?? this.rows, + ); + } } /// "Contribute action" element of the Knowledge panel. @@ -314,6 +444,16 @@ class KnowledgePanelActionElement extends JsonObject { @override Map toJson() => _$KnowledgePanelActionElementToJson(this); + + KnowledgePanelActionElement copyWith({ + String? html, + List? actions, + }) { + return KnowledgePanelActionElement( + html: html ?? this.html, + actions: actions ?? this.actions, + ); + } } /// The type of Knowledge panel. @@ -397,4 +537,26 @@ class KnowledgePanelElement extends JsonObject { @override Map toJson() => _$KnowledgePanelElementToJson(this); + + KnowledgePanelElement copyWith({ + KnowledgePanelElementType? elementType, + KnowledgePanelTextElement? textElement, + KnowledgePanelImageElement? imageElement, + KnowledgePanelPanelIdElement? panelElement, + KnowledgePanelPanelGroupElement? panelGroupElement, + KnowledgePanelTableElement? tableElement, + KnowledgePanelWorldMapElement? mapElement, + KnowledgePanelActionElement? actionElement, + }) { + return KnowledgePanelElement( + elementType: elementType ?? this.elementType, + textElement: textElement ?? this.textElement, + imageElement: imageElement ?? this.imageElement, + panelElement: panelElement ?? this.panelElement, + panelGroupElement: panelGroupElement ?? this.panelGroupElement, + tableElement: tableElement ?? this.tableElement, + mapElement: mapElement ?? this.mapElement, + actionElement: actionElement ?? this.actionElement, + ); + } } diff --git a/lib/src/model/leaderboard_entry.dart b/lib/src/model/leaderboard_entry.dart index 177416d055..af2b4fa358 100644 --- a/lib/src/model/leaderboard_entry.dart +++ b/lib/src/model/leaderboard_entry.dart @@ -27,4 +27,14 @@ class LeaderboardEntry extends JsonObject { String toString() => 'LeaderboardEntry(score: $score' '${userId == null ? ', no user id' : ', userId: $userId'}' ')'; + + LeaderboardEntry copyWith({ + String? userId, + int? score, + }) { + return LeaderboardEntry( + userId: userId ?? this.userId, + score: score ?? this.score, + ); + } } diff --git a/lib/src/model/login_status.dart b/lib/src/model/login_status.dart index 9851fe7c01..c5222ab3e6 100644 --- a/lib/src/model/login_status.dart +++ b/lib/src/model/login_status.dart @@ -52,4 +52,20 @@ class LoginStatus { '${userEmail == null ? '' : ',userEmail:$userEmail'}' '${userName == null ? '' : ',userName:$userName'}' ')'; + + LoginStatus copyWith({ + int? status, + String? statusVerbose, + String? userEmail, + String? userName, + String? userId, + }) { + return LoginStatus( + status: status ?? this.status, + statusVerbose: statusVerbose ?? this.statusVerbose, + userEmail: userEmail ?? this.userEmail, + userName: userName ?? this.userName, + userId: userId ?? this.userId, + ); + } } diff --git a/lib/src/model/ocr_ingredients_result.dart b/lib/src/model/ocr_ingredients_result.dart index 99b79dbb43..a8f1c6c262 100644 --- a/lib/src/model/ocr_ingredients_result.dart +++ b/lib/src/model/ocr_ingredients_result.dart @@ -25,4 +25,18 @@ class OcrIngredientsResult extends JsonObject { @JsonKey(name: 'ingredients_text_from_image') final String? ingredientsTextFromImage; + + OcrIngredientsResult copyWith({ + int? status, + String? ingredientsTextFromImageOrig, + String? ingredientsTextFromImage, + }) { + return OcrIngredientsResult( + status: status ?? this.status, + ingredientsTextFromImageOrig: + ingredientsTextFromImageOrig ?? this.ingredientsTextFromImageOrig, + ingredientsTextFromImage: + ingredientsTextFromImage ?? this.ingredientsTextFromImage, + ); + } } diff --git a/lib/src/model/ocr_packaging_result.dart b/lib/src/model/ocr_packaging_result.dart index afa26dc0a3..fd1e9d8dc3 100644 --- a/lib/src/model/ocr_packaging_result.dart +++ b/lib/src/model/ocr_packaging_result.dart @@ -25,4 +25,16 @@ class OcrPackagingResult extends JsonObject { @JsonKey(name: 'packaging_text_from_image') final String? textFromImage; + + OcrPackagingResult copyWith({ + int? status, + String? textFromImageOrig, + String? textFromImage, + }) { + return OcrPackagingResult( + status: status ?? this.status, + textFromImageOrig: textFromImageOrig ?? this.textFromImageOrig, + textFromImage: textFromImage ?? this.textFromImage, + ); + } } diff --git a/lib/src/model/product.dart b/lib/src/model/product.dart index e8ac415e8c..54ba9244ee 100644 --- a/lib/src/model/product.dart +++ b/lib/src/model/product.dart @@ -925,4 +925,165 @@ class Product extends JsonObject { } _nutriments = nutriments; } + + Product copyWith({ + String? barcode, + String? productName, + Map? productNameInLanguages, + String? genericName, + Map? genericNameInLanguages, + String? brands, + List? brandsTags, + Map>? brandsTagsInLanguages, + String? countries, + List? countriesTags, + Map>? countriesTagsInLanguages, + OpenFoodFactsLanguage? lang, + String? quantity, + String? imageFrontUrl, + String? imageFrontSmallUrl, + String? imageIngredientsUrl, + String? imageIngredientsSmallUrl, + String? imageNutritionUrl, + String? imageNutritionSmallUrl, + String? imagePackagingUrl, + String? imagePackagingSmallUrl, + String? servingSize, + double? servingQuantity, + double? packagingQuantity, + List? selectedImages, + List? images, + List? ingredients, + String? ingredientsText, + Map? ingredientsTextInLanguages, + List? ingredientsTags, + Map>? ingredientsTagsInLanguages, + Map>? + imagesFreshnessInLanguages, + IngredientsAnalysisTags? ingredientsAnalysisTags, + Map>? + ingredientsAnalysisTagsInLanguages, + Additives? additives, + Allergens? allergens, + NutrientLevels? nutrientLevels, + String? nutrimentEnergyUnit, + bool? nutritionData, + String? nutrimentDataPer, + String? nutriscore, + String? comparedToCategory, + String? categories, + List? categoriesTags, + Map>? categoriesTagsInLanguages, + String? labels, + List? labelsTags, + Map>? labelsTagsInLanguages, + String? packaging, + List? packagings, + bool? packagingsComplete, + List? packagingTags, + Map? packagingTextInLanguages, + List? miscTags, + Map>? miscTagsInLanguages, + List? statesTags, + Map>? statesTagsInLanguages, + List? tracesTags, + Map>? tracesTagsInLanguages, + List? storesTags, + Map>? storesTagsInLanguages, + String? stores, + List? attributeGroups, + DateTime? lastModified, + String? lastModifiedBy, + DateTime? lastImage, + String? lastEditor, + List? entryDates, + List? lastCheckDates, + List? lastEditDates, + List? lastImageDates, + DateTime? lastChecked, + String? lastChecker, + DateTime? created, + String? creator, + List? editors, + String? ecoscoreGrade, + double? ecoscoreScore, + EcoscoreData? ecoscoreData, + KnowledgePanels? knowledgePanels, + String? embCodes, + String? manufacturingPlaces, + String? origins, + int? novaGroup, + String? website, + Nutriments? nutriments, + bool? noNutritionData, + }) { + return Product( + barcode: barcode ?? this.barcode, + productName: productName ?? this.productName, + productNameInLanguages: + productNameInLanguages ?? this.productNameInLanguages, + genericName: genericName ?? this.genericName, + brands: brands ?? this.brands, + brandsTags: brandsTags ?? this.brandsTags, + countries: countries ?? this.countries, + countriesTags: countriesTags ?? this.countriesTags, + countriesTagsInLanguages: + countriesTagsInLanguages ?? this.countriesTagsInLanguages, + lang: lang ?? this.lang, + quantity: quantity ?? this.quantity, + imageFrontUrl: imageFrontUrl ?? this.imageFrontUrl, + imageFrontSmallUrl: imageFrontSmallUrl ?? this.imageFrontSmallUrl, + imageIngredientsUrl: imageIngredientsUrl ?? this.imageIngredientsUrl, + imageIngredientsSmallUrl: + imageIngredientsSmallUrl ?? this.imageIngredientsSmallUrl, + imageNutritionUrl: imageNutritionUrl ?? this.imageNutritionUrl, + imageNutritionSmallUrl: + imageNutritionSmallUrl ?? this.imageNutritionSmallUrl, + imagePackagingUrl: imagePackagingUrl ?? this.imagePackagingUrl, + imagePackagingSmallUrl: + imagePackagingSmallUrl ?? this.imagePackagingSmallUrl, + servingSize: servingSize ?? this.servingSize, + servingQuantity: servingQuantity ?? this.servingQuantity, + packagingQuantity: packagingQuantity ?? this.packagingQuantity, + selectedImages: selectedImages ?? this.selectedImages, + images: images ?? this.images, + ingredients: ingredients ?? this.ingredients, + ingredientsText: ingredientsText ?? this.ingredientsText, + ingredientsTextInLanguages: + ingredientsTextInLanguages ?? this.ingredientsTextInLanguages, + ingredientsTags: ingredientsTags ?? this.ingredientsTags, + ingredientsTagsInLanguages: + ingredientsTagsInLanguages ?? this.ingredientsTagsInLanguages, + ingredientsAnalysisTags: + ingredientsAnalysisTags ?? this.ingredientsAnalysisTags, + additives: additives ?? this.additives, + allergens: allergens ?? this.allergens, + nutrientLevels: nutrientLevels ?? this.nutrientLevels, + nutrimentEnergyUnit: nutrimentEnergyUnit ?? this.nutrimentEnergyUnit, + nutrimentDataPer: nutrimentDataPer ?? this.nutrimentDataPer, + nutriscore: nutriscore ?? this.nutriscore, + categories: categories ?? this.categories, + categoriesTags: categoriesTags ?? this.categoriesTags, + categoriesTagsInLanguages: + categoriesTagsInLanguages ?? this.categoriesTagsInLanguages, + labels: labels ?? this.labels, + labelsTags: labelsTags ?? this.labelsTags, + labelsTagsInLanguages: + labelsTagsInLanguages ?? this.labelsTagsInLanguages, + packaging: packaging ?? this.packaging, + packagingTags: packagingTags ?? this.packagingTags, + miscTags: miscTags ?? this.miscTags, + statesTags: statesTags ?? this.statesTags, + tracesTags: tracesTags ?? this.tracesTags, + storesTags: storesTags ?? this.storesTags, + stores: stores ?? this.stores, + attributeGroups: attributeGroups ?? this.attributeGroups, + lastModified: lastModified ?? this.lastModified, + ecoscoreGrade: ecoscoreGrade ?? this.ecoscoreGrade, + ecoscoreScore: ecoscoreScore ?? this.ecoscoreScore, + ecoscoreData: ecoscoreData ?? this.ecoscoreData, + nutriments: _nutriments, + noNutritionData: noNutritionData, + ); + } } diff --git a/lib/src/model/product_freshness.dart b/lib/src/model/product_freshness.dart index bfb6f801e8..78acf35851 100644 --- a/lib/src/model/product_freshness.dart +++ b/lib/src/model/product_freshness.dart @@ -38,4 +38,20 @@ class ProductFreshness { ',' 'improvements:$improvements' ')'; + + ProductFreshness copyWith({ + bool? isEcoscoreReady, + bool? isNutriscoreReady, + bool? isIngredientsReady, + DateTime? lastModified, + Set? improvements, + }) { + return ProductFreshness._( + isEcoscoreReady: isEcoscoreReady ?? this.isEcoscoreReady, + isNutriscoreReady: isNutriscoreReady ?? this.isNutriscoreReady, + isIngredientsReady: isIngredientsReady ?? this.isIngredientsReady, + lastModified: lastModified ?? this.lastModified, + improvements: improvements ?? this.improvements, + ); + } } diff --git a/lib/src/model/product_image.dart b/lib/src/model/product_image.dart index a71f5b0079..1a1590d6bf 100644 --- a/lib/src/model/product_image.dart +++ b/lib/src/model/product_image.dart @@ -196,4 +196,38 @@ class ProductImage { other.width == width && other.height == height; } + + ProductImage copyWith({ + ImageField? field, + ImageSize? size, + OpenFoodFactsLanguage? language, + String? url, + int? rev, + String? imgid, + ImageAngle? angle, + String? coordinatesImageSize, + int? x1, + int? y1, + int? x2, + int? y2, + int? width, + int? height, + }) { + return ProductImage( + field: field ?? this.field, + size: size ?? this.size, + language: language ?? this.language, + url: url ?? this.url, + rev: rev ?? this.rev, + imgid: imgid ?? this.imgid, + angle: angle ?? this.angle, + coordinatesImageSize: coordinatesImageSize ?? this.coordinatesImageSize, + x1: x1 ?? this.x1, + y1: y1 ?? this.y1, + x2: x2 ?? this.x2, + y2: y2 ?? this.y2, + width: width ?? this.width, + height: height ?? this.height, + ); + } } diff --git a/lib/src/model/product_list.dart b/lib/src/model/product_list.dart index 1800e10a0b..eab3076133 100644 --- a/lib/src/model/product_list.dart +++ b/lib/src/model/product_list.dart @@ -27,4 +27,16 @@ class ProductList extends JsonObject { @override String toString() => toJson().toString(); + + ProductList copyWith({ + String? barcode, + String? key, + String? value, + }) { + return ProductList( + barcode: barcode ?? this.barcode, + key: key ?? this.key, + value: value ?? this.value, + ); + } } diff --git a/lib/src/model/product_stats.dart b/lib/src/model/product_stats.dart index 4b463b77da..75014db57a 100644 --- a/lib/src/model/product_stats.dart +++ b/lib/src/model/product_stats.dart @@ -34,4 +34,18 @@ class ProductStats extends JsonObject { @override String toString() => toJson().toString(); + + ProductStats copyWith({ + String? barcode, + int? numberOfKeys, + int? numberOfEditors, + DateTime? lastEdit, + }) { + return ProductStats( + barcode: barcode ?? this.barcode, + numberOfKeys: numberOfKeys ?? this.numberOfKeys, + numberOfEditors: numberOfEditors ?? this.numberOfEditors, + lastEdit: lastEdit ?? this.lastEdit, + ); + } } diff --git a/lib/src/model/product_tag.dart b/lib/src/model/product_tag.dart index 5bdecbf6d6..fb5c2d1305 100644 --- a/lib/src/model/product_tag.dart +++ b/lib/src/model/product_tag.dart @@ -42,4 +42,26 @@ class ProductTag extends JsonObject { @override String toString() => toJson().toString(); + + ProductTag copyWith({ + String? barcode, + String? key, + String? value, + String? owner, + int? version, + String? editor, + DateTime? lastEdit, + String? comment, + }) { + return ProductTag( + barcode: barcode ?? this.barcode, + key: key ?? this.key, + value: value ?? this.value, + owner: owner ?? this.owner, + version: version ?? this.version, + editor: editor ?? this.editor, + lastEdit: lastEdit ?? this.lastEdit, + comment: comment ?? this.comment, + ); + } } diff --git a/lib/src/model/recommended_daily_intake.dart b/lib/src/model/recommended_daily_intake.dart index e2671d9761..df05b60d4f 100644 --- a/lib/src/model/recommended_daily_intake.dart +++ b/lib/src/model/recommended_daily_intake.dart @@ -117,6 +117,82 @@ class RecommendedDailyIntake { final IntakeRecommendation molybdenum; final IntakeRecommendation iodine; + RecommendedDailyIntake copyWith({ + IntakeRecommendation? energyKcal, + IntakeRecommendation? energyKj, + IntakeRecommendation? fat, + IntakeRecommendation? saturatedFat, + IntakeRecommendation? carbohydrates, + IntakeRecommendation? sugars, + IntakeRecommendation? proteins, + IntakeRecommendation? sodium, + IntakeRecommendation? vitaminA, + IntakeRecommendation? vitaminD, + IntakeRecommendation? vitaminE, + IntakeRecommendation? vitaminK, + IntakeRecommendation? vitaminC, + IntakeRecommendation? vitaminB1, + IntakeRecommendation? vitaminB2, + IntakeRecommendation? vitaminB3, + IntakeRecommendation? vitaminB6, + IntakeRecommendation? vitaminB9, + IntakeRecommendation? vitaminB12, + IntakeRecommendation? biotin, + IntakeRecommendation? pantothenicAcid, + IntakeRecommendation? potassium, + IntakeRecommendation? chloride, + IntakeRecommendation? calcium, + IntakeRecommendation? phosphorus, + IntakeRecommendation? magnesium, + IntakeRecommendation? iron, + IntakeRecommendation? zinc, + IntakeRecommendation? copper, + IntakeRecommendation? manganese, + IntakeRecommendation? fluoride, + IntakeRecommendation? selenium, + IntakeRecommendation? chromium, + IntakeRecommendation? molybdenum, + IntakeRecommendation? iodine, + }) { + return RecommendedDailyIntake( + energyKcal ?? this.energyKcal, + energyKj ?? this.energyKj, + fat ?? this.fat, + saturatedFat ?? this.saturatedFat, + carbohydrates ?? this.carbohydrates, + sugars ?? this.sugars, + proteins ?? this.proteins, + sodium ?? this.sodium, + vitaminA ?? this.vitaminA, + vitaminD ?? this.vitaminD, + vitaminE ?? this.vitaminE, + vitaminK ?? this.vitaminK, + vitaminC ?? this.vitaminC, + vitaminB1 ?? this.vitaminB1, + vitaminB2 ?? this.vitaminB2, + vitaminB3 ?? this.vitaminB3, + vitaminB6 ?? this.vitaminB6, + vitaminB9 ?? this.vitaminB9, + vitaminB12 ?? this.vitaminB12, + biotin ?? this.biotin, + pantothenicAcid ?? this.pantothenicAcid, + potassium ?? this.potassium, + chloride ?? this.chloride, + calcium ?? this.calcium, + phosphorus ?? this.phosphorus, + magnesium ?? this.magnesium, + iron ?? this.iron, + zinc ?? this.zinc, + copper ?? this.copper, + manganese ?? this.manganese, + fluoride ?? this.fluoride, + selenium ?? this.selenium, + chromium ?? this.chromium, + molybdenum ?? this.molybdenum, + iodine ?? this.iodine, + ); + } + // The plugin is unable to access the assets/json/recommended_daily_intakes_source _eu.json file. Looking for a fix. /*static Future> _loadRecommendationAsset() async { String jsonString = await rootBundle.loadString('assets/json/recommended_daily_intakes_source _eu.json'); diff --git a/lib/src/model/robotoff_question.dart b/lib/src/model/robotoff_question.dart index 7c6d68ce54..06c5552084 100644 --- a/lib/src/model/robotoff_question.dart +++ b/lib/src/model/robotoff_question.dart @@ -17,6 +17,16 @@ class RobotoffQuestionResult extends JsonObject { @override Map toJson() => _$RobotoffQuestionResultToJson(this); + + RobotoffQuestionResult copyWith({ + String? status, + List? questions, + }) { + return RobotoffQuestionResult( + status: status ?? this.status, + questions: questions ?? this.questions, + ); + } } @JsonSerializable() @@ -46,4 +56,24 @@ class RobotoffQuestion extends JsonObject { @override Map toJson() => _$RobotoffQuestionToJson(this); + + RobotoffQuestion copyWith({ + String? barcode, + String? type, + String? value, + String? question, + String? insightId, + InsightType? insightType, + String? imageUrl, + }) { + return RobotoffQuestion( + barcode: barcode ?? this.barcode, + type: type ?? this.type, + value: value ?? this.value, + question: question ?? this.question, + insightId: insightId ?? this.insightId, + insightType: insightType ?? this.insightType, + imageUrl: imageUrl ?? this.imageUrl, + ); + } } diff --git a/lib/src/model/search_result.dart b/lib/src/model/search_result.dart index 9b5ff5697f..7b869dd4b3 100644 --- a/lib/src/model/search_result.dart +++ b/lib/src/model/search_result.dart @@ -38,4 +38,22 @@ class SearchResult extends JsonObject { @override Map toJson() => _$SearchResultToJson(this); + + SearchResult copyWith({ + int? page, + int? pageSize, + int? count, + int? pageCount, + int? skip, + List? products, + }) { + return SearchResult( + page: page ?? this.page, + pageSize: pageSize ?? this.pageSize, + count: count ?? this.count, + pageCount: pageCount ?? this.pageCount, + skip: skip ?? this.skip, + products: products ?? this.products, + ); + } } diff --git a/lib/src/model/send_image.dart b/lib/src/model/send_image.dart index edc6af739e..fa242473af 100644 --- a/lib/src/model/send_image.dart +++ b/lib/src/model/send_image.dart @@ -44,4 +44,18 @@ class SendImage extends JsonObject { 'imagefield': _getImageFieldWithLang(), }; } + + SendImage copyWith({ + OpenFoodFactsLanguage? lang, + Uri? imageUri, + String? barcode, + ImageField? imageField, + }) { + return SendImage( + lang: lang ?? this.lang, + imageUri: imageUri ?? this.imageUri, + barcode: barcode ?? this.barcode, + imageField: imageField ?? this.imageField, + ); + } } diff --git a/lib/src/model/spelling_corrections.dart b/lib/src/model/spelling_corrections.dart index d2b3126b0d..6f31419006 100644 --- a/lib/src/model/spelling_corrections.dart +++ b/lib/src/model/spelling_corrections.dart @@ -35,6 +35,16 @@ class TermCorrections extends JsonObject { @override Map toJson() => _$TermCorrectionsToJson(this); + + TermCorrections copyWith({ + List? corrections, + double? score, + }) { + return TermCorrections( + corrections ?? this.corrections, + score ?? this.score, + ); + } } @JsonSerializable() @@ -58,4 +68,20 @@ class Correction extends JsonObject { @override Map toJson() => _$CorrectionToJson(this); + + Correction copyWith({ + String? correction, + String? original, + int? startOffset, + int? endOffset, + bool? isValid, + }) { + return Correction( + correction ?? this.correction, + original ?? this.original, + startOffset ?? this.startOffset, + endOffset ?? this.endOffset, + isValid ?? this.isValid, + ); + } } diff --git a/lib/src/model/status.dart b/lib/src/model/status.dart index 63e1ac5ca7..389cad04d5 100644 --- a/lib/src/model/status.dart +++ b/lib/src/model/status.dart @@ -97,4 +97,5 @@ class Status extends JsonObject { Map toJson() => _$StatusToJson(this); bool shouldOpenNewIssue() => status == serverErrorStatus; + } diff --git a/lib/src/model/taxonomy_additive.dart b/lib/src/model/taxonomy_additive.dart index aed570ff37..cc7958eead 100644 --- a/lib/src/model/taxonomy_additive.dart +++ b/lib/src/model/taxonomy_additive.dart @@ -300,6 +300,79 @@ class TaxonomyAdditive extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyAdditive copyWith({ + Map? additivesClasses, + Map? carbonFootprintFrFoodgesIngredient, + Map? carbonFootprintFrFoodgesValue, + List? children, + Map? colourIndex, + Map? comment, + Map? defaultAdditiveClass, + Map? description, + Map? eNumber, + Map? efsa, + Map? efsaEvaluation, + Map? efsaEvaluationAdi, + Map? efsaEvaluationAdiEstablished, + Map? efsaEvaluationDate, + Map? + efsaEvaluationExposure95thGreaterThanAdi, + Map? + efsaEvaluationExposure95thGreaterThanNoael, + Map? + efsaEvaluationExposureMeanGreaterThanAdi, + Map? + efsaEvaluationExposureMeanGreaterThanNoael, + Map? efsaEvaluationOverexposureRisk, + Map? efsaEvaluationSafetyAssessed, + Map? efsaEvaluationUrl, + Map? fromPalmOil, + Map? mandatoryAdditiveClass, + Map? name, + Map? organicEu, + List? parents, + Map? vegan, + Map? vegetarian, + Map? wikidata, + }) { + return TaxonomyAdditive( + additivesClasses ?? this.additivesClasses, + carbonFootprintFrFoodgesIngredient ?? + this.carbonFootprintFrFoodgesIngredient, + carbonFootprintFrFoodgesValue ?? this.carbonFootprintFrFoodgesValue, + children ?? this.children, + colourIndex ?? this.colourIndex, + comment ?? this.comment, + defaultAdditiveClass ?? this.defaultAdditiveClass, + description ?? this.description, + eNumber ?? this.eNumber, + efsa ?? this.efsa, + efsaEvaluation ?? this.efsaEvaluation, + efsaEvaluationAdi ?? this.efsaEvaluationAdi, + efsaEvaluationAdiEstablished ?? this.efsaEvaluationAdiEstablished, + efsaEvaluationDate ?? this.efsaEvaluationDate, + efsaEvaluationExposure95thGreaterThanAdi ?? + this.efsaEvaluationExposure95thGreaterThanAdi, + efsaEvaluationExposure95thGreaterThanNoael ?? + this.efsaEvaluationExposure95thGreaterThanNoael, + efsaEvaluationExposureMeanGreaterThanAdi ?? + this.efsaEvaluationExposureMeanGreaterThanAdi, + efsaEvaluationExposureMeanGreaterThanNoael ?? + this.efsaEvaluationExposureMeanGreaterThanNoael, + efsaEvaluationOverexposureRisk ?? this.efsaEvaluationOverexposureRisk, + efsaEvaluationSafetyAssessed ?? this.efsaEvaluationSafetyAssessed, + efsaEvaluationUrl ?? this.efsaEvaluationUrl, + fromPalmOil ?? this.fromPalmOil, + mandatoryAdditiveClass ?? this.mandatoryAdditiveClass, + name ?? this.name, + organicEu ?? this.organicEu, + parents ?? this.parents, + vegan ?? this.vegan, + vegetarian ?? this.vegetarian, + wikidata ?? this.wikidata, + ); + } } /// Configuration to get additives diff --git a/lib/src/model/taxonomy_allergen.dart b/lib/src/model/taxonomy_allergen.dart index f1337aeb57..35906a00b6 100644 --- a/lib/src/model/taxonomy_allergen.dart +++ b/lib/src/model/taxonomy_allergen.dart @@ -69,6 +69,18 @@ class TaxonomyAllergen extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyAllergen copyWith({ + Map? name, + Map>? synonyms, + Map? wikidata, + }) { + return TaxonomyAllergen( + name ?? this.name, + synonyms ?? this.synonyms, + wikidata ?? this.wikidata, + ); + } } /// Configuration for allergens API query. diff --git a/lib/src/model/taxonomy_category.dart b/lib/src/model/taxonomy_category.dart index 0f48fce2a3..e5e38fa4fb 100644 --- a/lib/src/model/taxonomy_category.dart +++ b/lib/src/model/taxonomy_category.dart @@ -294,6 +294,71 @@ class TaxonomyCategory extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyCategory copyWith({ + Map? agribalyseFoodCode, + Map? agribalyseFoodName, + Map? agribalyseProxyFoodCode, + Map? agribalyseProxyFoodName, + Map? agribalyseProxyName, + Map? carbonFootprintFrFoodgesIngredient, + List? children, + Map? ciqualFoodCode, + Map? ciqualFoodName, + Map? ciqualProxyFoodCode, + Map? ciqualProxyFoodName, + Map? country, + Map? grapevariety, + Map? instanceof, + Map? name, + Map? nova, + Map? oqaliFamily, + Map? origins, + List? parents, + Map? pnnsGroup1, + Map? pnnsGroup2, + Map? protectedNameFileNumber, + Map? protectedNameType, + Map? region, + Map? seasonInCountryFr, + Map? whoId, + Map? wikidata, + Map? wikidataCategory, + Map? wikidataWikipediaCategory, + }) { + return TaxonomyCategory( + agribalyseFoodCode ?? this.agribalyseFoodCode, + agribalyseFoodName ?? this.agribalyseFoodName, + agribalyseProxyFoodCode ?? this.agribalyseProxyFoodCode, + agribalyseProxyFoodName ?? this.agribalyseProxyFoodName, + agribalyseProxyName ?? this.agribalyseProxyName, + carbonFootprintFrFoodgesIngredient ?? + this.carbonFootprintFrFoodgesIngredient, + children ?? this.children, + ciqualFoodCode ?? this.ciqualFoodCode, + ciqualFoodName ?? this.ciqualFoodName, + ciqualProxyFoodCode ?? this.ciqualProxyFoodCode, + ciqualProxyFoodName ?? this.ciqualProxyFoodName, + country ?? this.country, + grapevariety ?? this.grapevariety, + instanceof ?? this.instanceof, + name ?? this.name, + nova ?? this.nova, + oqaliFamily ?? this.oqaliFamily, + origins ?? this.origins, + parents ?? this.parents, + pnnsGroup1 ?? this.pnnsGroup1, + pnnsGroup2 ?? this.pnnsGroup2, + protectedNameFileNumber ?? this.protectedNameFileNumber, + protectedNameType ?? this.protectedNameType, + region ?? this.region, + seasonInCountryFr ?? this.seasonInCountryFr, + whoId ?? this.whoId, + wikidata ?? this.wikidata, + wikidataCategory ?? this.wikidataCategory, + wikidataWikipediaCategory ?? this.wikidataWikipediaCategory, + ); + } } class TaxonomyCategoryQueryConfiguration extends TaxonomyQueryConfiguration< diff --git a/lib/src/model/taxonomy_ingredient.dart b/lib/src/model/taxonomy_ingredient.dart index d85fe4694e..98077c9248 100644 --- a/lib/src/model/taxonomy_ingredient.dart +++ b/lib/src/model/taxonomy_ingredient.dart @@ -420,6 +420,105 @@ class TaxonomyIngredient extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyIngredient copyWith({ + Map? additivesClasses, + Map? allergens, + Map? brioche, + Map? carbonFootprintFrFoodgesIngredient, + Map? carbonFootprintFrFoodgesValue, + List? children, + Map? ciqualFoodCode, + Map? ciqualFoodName, + Map? colourIndex, + Map? comment, + Map? defaultAdditiveClass, + Map? description, + Map? eNumber, + Map? efsa, + Map? efsaEvaluation, + Map? efsaEvaluationAdi, + Map? efsaEvaluationAdiEstablished, + Map? efsaEvaluationDate, + Map? + efsaEvaluationExposure95ThGreaterThanAdi, + Map? + efsaEvaluationExposure95ThGreaterThanNoael, + Map? + efsaEvaluationExposureMeanGreaterThanAdi, + Map? + efsaEvaluationExposureMeanGreaterThanNoael, + Map? efsaEvaluationOverexposureRisk, + Map? efsaEvaluationSafetyAssessed, + Map? efsaEvaluationUrl, + Map? fromPalmOil, + Map? likelyAllergens, + Map? mandatoryAdditiveClass, + Map? name, + Map? nova, + Map? nutriscoreFruitsVegetablesNuts, + Map? organicEu, + Map? origins, + List? parents, + Map? pnnsGroup2, + Map? protectedNameType, + Map? reblochon, + Map>? synonyms, + Map? vegan, + Map? vegetarian, + Map? wikidata, + Map? wiktionary, + }) { + return TaxonomyIngredient( + additivesClasses ?? this.additivesClasses, + allergens ?? this.allergens, + brioche ?? this.brioche, + carbonFootprintFrFoodgesIngredient ?? + this.carbonFootprintFrFoodgesIngredient, + carbonFootprintFrFoodgesValue ?? this.carbonFootprintFrFoodgesValue, + children ?? this.children, + ciqualFoodCode ?? this.ciqualFoodCode, + ciqualFoodName ?? this.ciqualFoodName, + colourIndex ?? this.colourIndex, + comment ?? this.comment, + defaultAdditiveClass ?? this.defaultAdditiveClass, + description ?? this.description, + eNumber ?? this.eNumber, + efsa ?? this.efsa, + efsaEvaluation ?? this.efsaEvaluation, + efsaEvaluationAdi ?? this.efsaEvaluationAdi, + efsaEvaluationAdiEstablished ?? this.efsaEvaluationAdiEstablished, + efsaEvaluationDate ?? this.efsaEvaluationDate, + efsaEvaluationExposure95ThGreaterThanAdi ?? + this.efsaEvaluationExposure95ThGreaterThanAdi, + efsaEvaluationExposure95ThGreaterThanNoael ?? + this.efsaEvaluationExposure95ThGreaterThanNoael, + efsaEvaluationExposureMeanGreaterThanAdi ?? + this.efsaEvaluationExposureMeanGreaterThanAdi, + efsaEvaluationExposureMeanGreaterThanNoael ?? + this.efsaEvaluationExposureMeanGreaterThanNoael, + efsaEvaluationOverexposureRisk ?? this.efsaEvaluationOverexposureRisk, + efsaEvaluationSafetyAssessed ?? this.efsaEvaluationSafetyAssessed, + efsaEvaluationUrl ?? this.efsaEvaluationUrl, + fromPalmOil ?? this.fromPalmOil, + likelyAllergens ?? this.likelyAllergens, + mandatoryAdditiveClass ?? this.mandatoryAdditiveClass, + name ?? this.name, + nova ?? this.nova, + nutriscoreFruitsVegetablesNuts ?? this.nutriscoreFruitsVegetablesNuts, + organicEu ?? this.organicEu, + origins ?? this.origins, + parents ?? this.parents, + pnnsGroup2 ?? this.pnnsGroup2, + protectedNameType ?? this.protectedNameType, + reblochon ?? this.reblochon, + synonyms ?? this.synonyms, + vegan ?? this.vegan, + vegetarian ?? this.vegetarian, + wikidata ?? this.wikidata, + wiktionary ?? this.wiktionary, + ); + } } class TaxonomyIngredientQueryConfiguration extends TaxonomyQueryConfiguration< diff --git a/lib/src/model/taxonomy_label.dart b/lib/src/model/taxonomy_label.dart index e81bfa22bd..2ecc0a4d35 100644 --- a/lib/src/model/taxonomy_label.dart +++ b/lib/src/model/taxonomy_label.dart @@ -248,6 +248,60 @@ class TaxonomyLabel extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyLabel copyWith({ + Map? authAddress, + Map? authName, + Map? authUrl, + Map? categories, + Map? countriesWhereSold, + List? children, + Map? country, + Map? description, + Map? euGroups, + Map? exceptions, + Map? image, + Map? images, + Map? ingredients, + Map? labelCategories, + Map? manufacturingPlaces, + Map? name, + Map? opposite, + Map? origins, + Map? packaging, + Map? packagingPlaces, + List? parents, + Map? protectedNameType, + Map? stores, + Map? wikidata, + }) { + return TaxonomyLabel( + authAddress ?? this.authAddress, + authName ?? this.authName, + authUrl ?? this.authUrl, + categories ?? this.categories, + children ?? this.children, + countriesWhereSold ?? this.countriesWhereSold, + country ?? this.country, + description ?? this.description, + euGroups ?? this.euGroups, + exceptions ?? this.exceptions, + image ?? this.image, + images ?? this.images, + ingredients ?? this.ingredients, + labelCategories ?? this.labelCategories, + manufacturingPlaces ?? this.manufacturingPlaces, + name ?? this.name, + opposite ?? this.opposite, + origins ?? this.origins, + packaging ?? this.packaging, + packagingPlaces ?? this.packagingPlaces, + parents ?? this.parents, + protectedNameType ?? this.protectedNameType, + stores ?? this.stores, + wikidata ?? this.wikidata, + ); + } } class TaxonomyLabelQueryConfiguration diff --git a/lib/src/model/taxonomy_language.dart b/lib/src/model/taxonomy_language.dart index a9c8b26055..e30f64b599 100644 --- a/lib/src/model/taxonomy_language.dart +++ b/lib/src/model/taxonomy_language.dart @@ -78,6 +78,20 @@ class TaxonomyLanguage extends JsonObject { @override String toString() => toJson().toString(); + + TaxonomyLanguage copyWith({ + Map? languageCode2, + Map? languageCode3, + Map? name, + Map? wikidata, + }) { + return TaxonomyLanguage( + languageCode2 ?? this.languageCode2, + languageCode3 ?? this.languageCode3, + name ?? this.name, + wikidata ?? this.wikidata, + ); + } } /// Configuration for languages API query. diff --git a/lib/src/model/taxonomy_packaging_shape.dart b/lib/src/model/taxonomy_packaging_shape.dart index 697a37e97d..241324b12e 100644 --- a/lib/src/model/taxonomy_packaging_shape.dart +++ b/lib/src/model/taxonomy_packaging_shape.dart @@ -120,4 +120,6 @@ class TaxonomyPackagingShapeQueryConfiguration .where((TaxonomyPackagingShapeField field) => !ignoredFields.contains(field)) .map((TaxonomyPackagingShapeField field) => field.offTag); + + } diff --git a/lib/src/model/user.dart b/lib/src/model/user.dart index 8bd9de3337..68881511aa 100644 --- a/lib/src/model/user.dart +++ b/lib/src/model/user.dart @@ -23,4 +23,16 @@ class User extends JsonObject { @override Map toJson() => _$UserToJson(this); + + User copyWith({ + String? comment, + String? userId, + String? password, + }) { + return User( + comment: comment ?? this.comment, + userId: userId ?? this.userId, + password: password ?? this.password, + ); + } } diff --git a/lib/src/model/user_agent.dart b/lib/src/model/user_agent.dart index e729f6b308..8feee04313 100644 --- a/lib/src/model/user_agent.dart +++ b/lib/src/model/user_agent.dart @@ -36,4 +36,20 @@ class UserAgent extends JsonObject { 'url': url, 'comment': comment, }; + + UserAgent copyWith({ + String? name, + String? version, + String? system, + String? url, + String? comment, + }) { + return UserAgent( + name: name ?? this.name, + version: version ?? this.version, + system: system ?? this.system, + url: url ?? this.url, + comment: comment ?? this.comment, + ); + } }