1 /*
2  * Copyright (C) 2023 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package android.health.connect.datatypes;
17 
18 import static android.health.connect.datatypes.RecordTypeIdentifier.RECORD_TYPE_NUTRITION;
19 import static android.health.connect.datatypes.validation.ValidationUtils.requireInRangeIfExists;
20 import static android.health.connect.datatypes.validation.ValidationUtils.validateIntDefValue;
21 
22 import android.annotation.NonNull;
23 import android.annotation.Nullable;
24 import android.health.connect.HealthConnectManager;
25 import android.health.connect.datatypes.units.Energy;
26 import android.health.connect.datatypes.units.Mass;
27 import android.health.connect.internal.datatypes.NutritionRecordInternal;
28 
29 import java.time.Instant;
30 import java.time.ZoneOffset;
31 import java.util.Objects;
32 
33 /** Captures what nutrients were consumed as part of a meal or a food item. */
34 @Identifier(recordIdentifier = RECORD_TYPE_NUTRITION)
35 public final class NutritionRecord extends IntervalRecord {
36     private static final Energy ENERGY_0_0 = Energy.fromCalories(0.0);
37     private static final Mass MASS_0_0 = Mass.fromGrams(0.0);
38     private static final Mass MASS_100 = Mass.fromGrams(100.0);
39     private static final Mass MASS_100000 = Mass.fromGrams(100000.0);
40 
41     /** Builder class for {@link NutritionRecord} */
42     public static final class Builder {
43         private final Metadata mMetadata;
44         private final Instant mStartTime;
45         private final Instant mEndTime;
46         private ZoneOffset mStartZoneOffset;
47         private ZoneOffset mEndZoneOffset;
48         private Mass mUnsaturatedFat;
49         private Mass mPotassium;
50         private Mass mThiamin;
51         private int mMealType;
52         private Mass mTransFat;
53         private Mass mManganese;
54         private Energy mEnergyFromFat;
55         private Mass mCaffeine;
56         private Mass mDietaryFiber;
57         private Mass mSelenium;
58         private Mass mVitaminB6;
59         private Mass mProtein;
60         private Mass mChloride;
61         private Mass mCholesterol;
62         private Mass mCopper;
63         private Mass mIodine;
64         private Mass mVitaminB12;
65         private Mass mZinc;
66         private Mass mRiboflavin;
67         private Energy mEnergy;
68         private Mass mMolybdenum;
69         private Mass mPhosphorus;
70         private Mass mChromium;
71         private Mass mTotalFat;
72         private Mass mCalcium;
73         private Mass mVitaminC;
74         private Mass mVitaminE;
75         private Mass mBiotin;
76         private Mass mVitaminD;
77         private Mass mNiacin;
78         private Mass mMagnesium;
79         private Mass mTotalCarbohydrate;
80         private Mass mVitaminK;
81         private Mass mPolyunsaturatedFat;
82         private Mass mSaturatedFat;
83         private Mass mSodium;
84         private Mass mFolate;
85         private Mass mMonounsaturatedFat;
86         private Mass mPantothenicAcid;
87         private String mMealName;
88         private Mass mIron;
89         private Mass mVitaminA;
90         private Mass mFolicAcid;
91         private Mass mSugar;
92 
93         /**
94          * @param metadata Metadata to be associated with the record. See {@link Metadata}.
95          * @param startTime Start time of this activity
96          * @param endTime End time of this activity
97          */
98         @SuppressWarnings("NullAway.Init") // TODO(b/317029272): fix this suppression
Builder( @onNull Metadata metadata, @NonNull Instant startTime, @NonNull Instant endTime)99         public Builder(
100                 @NonNull Metadata metadata, @NonNull Instant startTime, @NonNull Instant endTime) {
101             Objects.requireNonNull(metadata);
102             Objects.requireNonNull(startTime);
103             Objects.requireNonNull(endTime);
104             mMetadata = metadata;
105             mStartTime = startTime;
106             mEndTime = endTime;
107             mStartZoneOffset = ZoneOffset.systemDefault().getRules().getOffset(startTime);
108             mEndZoneOffset = ZoneOffset.systemDefault().getRules().getOffset(endTime);
109         }
110 
111         /** Sets the zone offset of the user when the activity started */
112         @NonNull
setStartZoneOffset(@onNull ZoneOffset startZoneOffset)113         public Builder setStartZoneOffset(@NonNull ZoneOffset startZoneOffset) {
114             Objects.requireNonNull(startZoneOffset);
115 
116             mStartZoneOffset = startZoneOffset;
117             return this;
118         }
119 
120         /** Sets the zone offset of the user when the activity ended */
121         @NonNull
setEndZoneOffset(@onNull ZoneOffset endZoneOffset)122         public Builder setEndZoneOffset(@NonNull ZoneOffset endZoneOffset) {
123             Objects.requireNonNull(endZoneOffset);
124 
125             mEndZoneOffset = endZoneOffset;
126             return this;
127         }
128 
129         /** Sets the start zone offset of this record to system default. */
130         @NonNull
clearStartZoneOffset()131         public Builder clearStartZoneOffset() {
132             mStartZoneOffset = RecordUtils.getDefaultZoneOffset();
133             return this;
134         }
135 
136         /** Sets the start zone offset of this record to system default. */
137         @NonNull
clearEndZoneOffset()138         public Builder clearEndZoneOffset() {
139             mEndZoneOffset = RecordUtils.getDefaultZoneOffset();
140             return this;
141         }
142 
143         /**
144          * Sets the unsaturatedFat of this activity
145          *
146          * @param unsaturatedFat UnsaturatedFat of this activity
147          */
148         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
149         @NonNull
setUnsaturatedFat(@ullable Mass unsaturatedFat)150         public Builder setUnsaturatedFat(@Nullable Mass unsaturatedFat) {
151             mUnsaturatedFat = unsaturatedFat;
152             return this;
153         }
154 
155         /**
156          * Sets the potassium of this activity
157          *
158          * @param potassium Potassium of this activity
159          */
160         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
161         @NonNull
setPotassium(@ullable Mass potassium)162         public Builder setPotassium(@Nullable Mass potassium) {
163             mPotassium = potassium;
164             return this;
165         }
166 
167         /**
168          * Sets the thiamin of this activity
169          *
170          * @param thiamin Thiamin of this activity
171          */
172         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
173         @NonNull
setThiamin(@ullable Mass thiamin)174         public Builder setThiamin(@Nullable Mass thiamin) {
175             mThiamin = thiamin;
176             return this;
177         }
178 
179         /**
180          * Sets the mealType of this activity
181          *
182          * @param mealType MealType of this activity
183          */
184         @NonNull
setMealType(@ealType.MealTypes int mealType)185         public Builder setMealType(@MealType.MealTypes int mealType) {
186             mMealType = mealType;
187             return this;
188         }
189 
190         /**
191          * Sets the transFat of this activity
192          *
193          * @param transFat TransFat of this activity
194          */
195         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
196         @NonNull
setTransFat(@ullable Mass transFat)197         public Builder setTransFat(@Nullable Mass transFat) {
198             mTransFat = transFat;
199             return this;
200         }
201 
202         /**
203          * Sets the manganese of this activity
204          *
205          * @param manganese Manganese of this activity
206          */
207         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
208         @NonNull
setManganese(@ullable Mass manganese)209         public Builder setManganese(@Nullable Mass manganese) {
210             mManganese = manganese;
211             return this;
212         }
213 
214         /**
215          * Sets the energyFromFat of this activity
216          *
217          * @param energyFromFat EnergyFromFat of this activity
218          */
219         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
220         @NonNull
setEnergyFromFat(@ullable Energy energyFromFat)221         public Builder setEnergyFromFat(@Nullable Energy energyFromFat) {
222             mEnergyFromFat = energyFromFat;
223             return this;
224         }
225 
226         /**
227          * Sets the caffeine of this activity
228          *
229          * @param caffeine Caffeine of this activity
230          */
231         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
232         @NonNull
setCaffeine(@ullable Mass caffeine)233         public Builder setCaffeine(@Nullable Mass caffeine) {
234             mCaffeine = caffeine;
235             return this;
236         }
237 
238         /**
239          * Sets the dietaryFiber of this activity
240          *
241          * @param dietaryFiber DietaryFiber of this activity
242          */
243         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
244         @NonNull
setDietaryFiber(@ullable Mass dietaryFiber)245         public Builder setDietaryFiber(@Nullable Mass dietaryFiber) {
246             mDietaryFiber = dietaryFiber;
247             return this;
248         }
249 
250         /**
251          * Sets the selenium of this activity
252          *
253          * @param selenium Selenium of this activity
254          */
255         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
256         @NonNull
setSelenium(@ullable Mass selenium)257         public Builder setSelenium(@Nullable Mass selenium) {
258             mSelenium = selenium;
259             return this;
260         }
261 
262         /**
263          * Sets the vitaminB6 of this activity
264          *
265          * @param vitaminB6 VitaminB6 of this activity
266          */
267         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
268         @NonNull
setVitaminB6(@ullable Mass vitaminB6)269         public Builder setVitaminB6(@Nullable Mass vitaminB6) {
270             mVitaminB6 = vitaminB6;
271             return this;
272         }
273 
274         /**
275          * Sets the protein of this activity
276          *
277          * @param protein Protein of this activity
278          */
279         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
280         @NonNull
setProtein(@ullable Mass protein)281         public Builder setProtein(@Nullable Mass protein) {
282             mProtein = protein;
283             return this;
284         }
285 
286         /**
287          * Sets the chloride of this activity
288          *
289          * @param chloride Chloride of this activity
290          */
291         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
292         @NonNull
setChloride(@ullable Mass chloride)293         public Builder setChloride(@Nullable Mass chloride) {
294             mChloride = chloride;
295             return this;
296         }
297 
298         /**
299          * Sets the cholesterol of this activity
300          *
301          * @param cholesterol Cholesterol of this activity
302          */
303         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
304         @NonNull
setCholesterol(@ullable Mass cholesterol)305         public Builder setCholesterol(@Nullable Mass cholesterol) {
306             mCholesterol = cholesterol;
307             return this;
308         }
309 
310         /**
311          * Sets the copper of this activity
312          *
313          * @param copper Copper of this activity
314          */
315         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
316         @NonNull
setCopper(@ullable Mass copper)317         public Builder setCopper(@Nullable Mass copper) {
318             mCopper = copper;
319             return this;
320         }
321 
322         /**
323          * Sets the iodine of this activity
324          *
325          * @param iodine Iodine of this activity
326          */
327         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
328         @NonNull
setIodine(@ullable Mass iodine)329         public Builder setIodine(@Nullable Mass iodine) {
330             mIodine = iodine;
331             return this;
332         }
333 
334         /**
335          * Sets the vitaminB12 of this activity
336          *
337          * @param vitaminB12 VitaminB12 of this activity
338          */
339         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
340         @NonNull
setVitaminB12(@ullable Mass vitaminB12)341         public Builder setVitaminB12(@Nullable Mass vitaminB12) {
342             mVitaminB12 = vitaminB12;
343             return this;
344         }
345 
346         /**
347          * Sets the zinc of this activity
348          *
349          * @param zinc Zinc of this activity
350          */
351         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
352         @NonNull
setZinc(@ullable Mass zinc)353         public Builder setZinc(@Nullable Mass zinc) {
354             mZinc = zinc;
355             return this;
356         }
357 
358         /**
359          * Sets the riboflavin of this activity
360          *
361          * @param riboflavin Riboflavin of this activity
362          */
363         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
364         @NonNull
setRiboflavin(@ullable Mass riboflavin)365         public Builder setRiboflavin(@Nullable Mass riboflavin) {
366             mRiboflavin = riboflavin;
367             return this;
368         }
369 
370         /**
371          * Sets the energy of this activity
372          *
373          * @param energy Energy of this activity
374          */
375         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
376         @NonNull
setEnergy(@ullable Energy energy)377         public Builder setEnergy(@Nullable Energy energy) {
378             mEnergy = energy;
379             return this;
380         }
381 
382         /**
383          * Sets the molybdenum of this activity
384          *
385          * @param molybdenum Molybdenum of this activity
386          */
387         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
388         @NonNull
setMolybdenum(@ullable Mass molybdenum)389         public Builder setMolybdenum(@Nullable Mass molybdenum) {
390             mMolybdenum = molybdenum;
391             return this;
392         }
393 
394         /**
395          * Sets the phosphorus of this activity
396          *
397          * @param phosphorus Phosphorus of this activity
398          */
399         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
400         @NonNull
setPhosphorus(@ullable Mass phosphorus)401         public Builder setPhosphorus(@Nullable Mass phosphorus) {
402             mPhosphorus = phosphorus;
403             return this;
404         }
405 
406         /**
407          * Sets the chromium of this activity
408          *
409          * @param chromium Chromium of this activity
410          */
411         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
412         @NonNull
setChromium(@ullable Mass chromium)413         public Builder setChromium(@Nullable Mass chromium) {
414             mChromium = chromium;
415             return this;
416         }
417 
418         /**
419          * Sets the totalFat of this activity
420          *
421          * @param totalFat TotalFat of this activity
422          */
423         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
424         @NonNull
setTotalFat(@ullable Mass totalFat)425         public Builder setTotalFat(@Nullable Mass totalFat) {
426             mTotalFat = totalFat;
427             return this;
428         }
429 
430         /**
431          * Sets the calcium of this activity
432          *
433          * @param calcium Calcium of this activity
434          */
435         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
436         @NonNull
setCalcium(@ullable Mass calcium)437         public Builder setCalcium(@Nullable Mass calcium) {
438             mCalcium = calcium;
439             return this;
440         }
441 
442         /**
443          * Sets the vitaminC of this activity
444          *
445          * @param vitaminC VitaminC of this activity
446          */
447         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
448         @NonNull
setVitaminC(@ullable Mass vitaminC)449         public Builder setVitaminC(@Nullable Mass vitaminC) {
450             mVitaminC = vitaminC;
451             return this;
452         }
453 
454         /**
455          * Sets the vitaminE of this activity
456          *
457          * @param vitaminE VitaminE of this activity
458          */
459         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
460         @NonNull
setVitaminE(@ullable Mass vitaminE)461         public Builder setVitaminE(@Nullable Mass vitaminE) {
462             mVitaminE = vitaminE;
463             return this;
464         }
465 
466         /**
467          * Sets the biotin of this activity
468          *
469          * @param biotin Biotin of this activity
470          */
471         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
472         @NonNull
setBiotin(@ullable Mass biotin)473         public Builder setBiotin(@Nullable Mass biotin) {
474             mBiotin = biotin;
475             return this;
476         }
477 
478         /**
479          * Sets the vitaminD of this activity
480          *
481          * @param vitaminD VitaminD of this activity
482          */
483         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
484         @NonNull
setVitaminD(@ullable Mass vitaminD)485         public Builder setVitaminD(@Nullable Mass vitaminD) {
486             mVitaminD = vitaminD;
487             return this;
488         }
489 
490         /**
491          * Sets the niacin of this activity
492          *
493          * @param niacin Niacin of this activity
494          */
495         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
496         @NonNull
setNiacin(@ullable Mass niacin)497         public Builder setNiacin(@Nullable Mass niacin) {
498             mNiacin = niacin;
499             return this;
500         }
501 
502         /**
503          * Sets the magnesium of this activity
504          *
505          * @param magnesium Magnesium of this activity
506          */
507         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
508         @NonNull
setMagnesium(@ullable Mass magnesium)509         public Builder setMagnesium(@Nullable Mass magnesium) {
510             mMagnesium = magnesium;
511             return this;
512         }
513 
514         /**
515          * Sets the totalCarbohydrate of this activity
516          *
517          * @param totalCarbohydrate TotalCarbohydrate of this activity
518          */
519         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
520         @NonNull
setTotalCarbohydrate(@ullable Mass totalCarbohydrate)521         public Builder setTotalCarbohydrate(@Nullable Mass totalCarbohydrate) {
522             mTotalCarbohydrate = totalCarbohydrate;
523             return this;
524         }
525 
526         /**
527          * Sets the vitaminK of this activity
528          *
529          * @param vitaminK VitaminK of this activity
530          */
531         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
532         @NonNull
setVitaminK(@ullable Mass vitaminK)533         public Builder setVitaminK(@Nullable Mass vitaminK) {
534             mVitaminK = vitaminK;
535             return this;
536         }
537 
538         /**
539          * Sets the polyunsaturatedFat of this activity
540          *
541          * @param polyunsaturatedFat PolyunsaturatedFat of this activity
542          */
543         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
544         @NonNull
setPolyunsaturatedFat(@ullable Mass polyunsaturatedFat)545         public Builder setPolyunsaturatedFat(@Nullable Mass polyunsaturatedFat) {
546             mPolyunsaturatedFat = polyunsaturatedFat;
547             return this;
548         }
549 
550         /**
551          * Sets the saturatedFat of this activity
552          *
553          * @param saturatedFat SaturatedFat of this activity
554          */
555         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
556         @NonNull
setSaturatedFat(@ullable Mass saturatedFat)557         public Builder setSaturatedFat(@Nullable Mass saturatedFat) {
558             mSaturatedFat = saturatedFat;
559             return this;
560         }
561 
562         /**
563          * Sets the sodium of this activity
564          *
565          * @param sodium Sodium of this activity
566          */
567         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
568         @NonNull
setSodium(@ullable Mass sodium)569         public Builder setSodium(@Nullable Mass sodium) {
570             mSodium = sodium;
571             return this;
572         }
573 
574         /**
575          * Sets the folate of this activity
576          *
577          * @param folate Folate of this activity
578          */
579         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
580         @NonNull
setFolate(@ullable Mass folate)581         public Builder setFolate(@Nullable Mass folate) {
582             mFolate = folate;
583             return this;
584         }
585 
586         /**
587          * Sets the monounsaturatedFat of this activity
588          *
589          * @param monounsaturatedFat MonounsaturatedFat of this activity
590          */
591         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
592         @NonNull
setMonounsaturatedFat(@ullable Mass monounsaturatedFat)593         public Builder setMonounsaturatedFat(@Nullable Mass monounsaturatedFat) {
594             mMonounsaturatedFat = monounsaturatedFat;
595             return this;
596         }
597 
598         /**
599          * Sets the pantothenicAcid of this activity
600          *
601          * @param pantothenicAcid PantothenicAcid of this activity
602          */
603         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
604         @NonNull
setPantothenicAcid(@ullable Mass pantothenicAcid)605         public Builder setPantothenicAcid(@Nullable Mass pantothenicAcid) {
606             mPantothenicAcid = pantothenicAcid;
607             return this;
608         }
609 
610         /**
611          * Sets the name of this activity
612          *
613          * @param mealName Name of this activity
614          */
615         @NonNull
setMealName(@onNull String mealName)616         public Builder setMealName(@NonNull String mealName) {
617             mMealName = mealName;
618             return this;
619         }
620 
621         /**
622          * Sets the iron of this activity
623          *
624          * @param iron Iron of this activity
625          */
626         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
627         @NonNull
setIron(@ullable Mass iron)628         public Builder setIron(@Nullable Mass iron) {
629             mIron = iron;
630             return this;
631         }
632 
633         /**
634          * Sets the vitaminA of this activity
635          *
636          * @param vitaminA VitaminA of this activity
637          */
638         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
639         @NonNull
setVitaminA(@ullable Mass vitaminA)640         public Builder setVitaminA(@Nullable Mass vitaminA) {
641             mVitaminA = vitaminA;
642             return this;
643         }
644 
645         /**
646          * Sets the folicAcid of this activity
647          *
648          * @param folicAcid FolicAcid of this activity
649          */
650         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
651         @NonNull
setFolicAcid(@ullable Mass folicAcid)652         public Builder setFolicAcid(@Nullable Mass folicAcid) {
653             mFolicAcid = folicAcid;
654             return this;
655         }
656 
657         /**
658          * Sets the sugar of this activity
659          *
660          * @param sugar Sugar of this activity
661          */
662         @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
663         @NonNull
setSugar(@ullable Mass sugar)664         public Builder setSugar(@Nullable Mass sugar) {
665             mSugar = sugar;
666             return this;
667         }
668 
669         /**
670          * @return Object of {@link NutritionRecord} without validating the values.
671          * @hide
672          */
673         @NonNull
buildWithoutValidation()674         public NutritionRecord buildWithoutValidation() {
675             return new NutritionRecord(
676                     mMetadata,
677                     mStartTime,
678                     mStartZoneOffset,
679                     mEndTime,
680                     mEndZoneOffset,
681                     mUnsaturatedFat,
682                     mPotassium,
683                     mThiamin,
684                     mMealType,
685                     mTransFat,
686                     mManganese,
687                     mEnergyFromFat,
688                     mCaffeine,
689                     mDietaryFiber,
690                     mSelenium,
691                     mVitaminB6,
692                     mProtein,
693                     mChloride,
694                     mCholesterol,
695                     mCopper,
696                     mIodine,
697                     mVitaminB12,
698                     mZinc,
699                     mRiboflavin,
700                     mEnergy,
701                     mMolybdenum,
702                     mPhosphorus,
703                     mChromium,
704                     mTotalFat,
705                     mCalcium,
706                     mVitaminC,
707                     mVitaminE,
708                     mBiotin,
709                     mVitaminD,
710                     mNiacin,
711                     mMagnesium,
712                     mTotalCarbohydrate,
713                     mVitaminK,
714                     mPolyunsaturatedFat,
715                     mSaturatedFat,
716                     mSodium,
717                     mFolate,
718                     mMonounsaturatedFat,
719                     mPantothenicAcid,
720                     mMealName,
721                     mIron,
722                     mVitaminA,
723                     mFolicAcid,
724                     mSugar,
725                     true);
726         }
727 
728         /**
729          * @return Object of {@link NutritionRecord}
730          */
731         @NonNull
build()732         public NutritionRecord build() {
733             return new NutritionRecord(
734                     mMetadata,
735                     mStartTime,
736                     mStartZoneOffset,
737                     mEndTime,
738                     mEndZoneOffset,
739                     mUnsaturatedFat,
740                     mPotassium,
741                     mThiamin,
742                     mMealType,
743                     mTransFat,
744                     mManganese,
745                     mEnergyFromFat,
746                     mCaffeine,
747                     mDietaryFiber,
748                     mSelenium,
749                     mVitaminB6,
750                     mProtein,
751                     mChloride,
752                     mCholesterol,
753                     mCopper,
754                     mIodine,
755                     mVitaminB12,
756                     mZinc,
757                     mRiboflavin,
758                     mEnergy,
759                     mMolybdenum,
760                     mPhosphorus,
761                     mChromium,
762                     mTotalFat,
763                     mCalcium,
764                     mVitaminC,
765                     mVitaminE,
766                     mBiotin,
767                     mVitaminD,
768                     mNiacin,
769                     mMagnesium,
770                     mTotalCarbohydrate,
771                     mVitaminK,
772                     mPolyunsaturatedFat,
773                     mSaturatedFat,
774                     mSodium,
775                     mFolate,
776                     mMonounsaturatedFat,
777                     mPantothenicAcid,
778                     mMealName,
779                     mIron,
780                     mVitaminA,
781                     mFolicAcid,
782                     mSugar,
783                     false);
784         }
785     }
786 
787     /**
788      * Metric identifier to get total biotin using aggregate APIs in {@link HealthConnectManager}
789      */
790     @NonNull
791     public static final AggregationType<Mass> BIOTIN_TOTAL =
792             new AggregationType<>(
793                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_BIOTIN_TOTAL,
794                     AggregationType.SUM,
795                     RECORD_TYPE_NUTRITION,
796                     Mass.class);
797 
798     /**
799      * Metric identifier to get total caffeine using aggregate APIs in {@link HealthConnectManager}
800      */
801     @NonNull
802     public static final AggregationType<Mass> CAFFEINE_TOTAL =
803             new AggregationType<>(
804                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_CAFFEINE_TOTAL,
805                     AggregationType.SUM,
806                     RECORD_TYPE_NUTRITION,
807                     Mass.class);
808 
809     /**
810      * Metric identifier to get total calcium using aggregate APIs in {@link HealthConnectManager}
811      */
812     @NonNull
813     public static final AggregationType<Mass> CALCIUM_TOTAL =
814             new AggregationType<>(
815                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_CALCIUM_TOTAL,
816                     AggregationType.SUM,
817                     RECORD_TYPE_NUTRITION,
818                     Mass.class);
819 
820     /**
821      * Metric identifier to get total chloride using aggregate APIs in {@link HealthConnectManager}
822      */
823     @NonNull
824     public static final AggregationType<Mass> CHLORIDE_TOTAL =
825             new AggregationType<>(
826                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_CHLORIDE_TOTAL,
827                     AggregationType.SUM,
828                     RECORD_TYPE_NUTRITION,
829                     Mass.class);
830 
831     /**
832      * Metric identifier to get total cholesterol using aggregate APIs in {@link
833      * HealthConnectManager}
834      */
835     @NonNull
836     public static final AggregationType<Mass> CHOLESTEROL_TOTAL =
837             new AggregationType<>(
838                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_CHOLESTEROL_TOTAL,
839                     AggregationType.SUM,
840                     RECORD_TYPE_NUTRITION,
841                     Mass.class);
842 
843     /**
844      * Metric identifier to get total chromium using aggregate APIs in {@link HealthConnectManager}
845      */
846     @NonNull
847     public static final AggregationType<Mass> CHROMIUM_TOTAL =
848             new AggregationType<>(
849                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_CHROMIUM_TOTAL,
850                     AggregationType.SUM,
851                     RECORD_TYPE_NUTRITION,
852                     Mass.class);
853 
854     /**
855      * Metric identifier to get total copper using aggregate APIs in {@link HealthConnectManager}
856      */
857     @NonNull
858     public static final AggregationType<Mass> COPPER_TOTAL =
859             new AggregationType<>(
860                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_COPPER_TOTAL,
861                     AggregationType.SUM,
862                     RECORD_TYPE_NUTRITION,
863                     Mass.class);
864 
865     /**
866      * Metric identifier to get total dietary fibre using aggregate APIs in {@link
867      * HealthConnectManager}
868      */
869     @NonNull
870     public static final AggregationType<Mass> DIETARY_FIBER_TOTAL =
871             new AggregationType<>(
872                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_DIETARY_FIBER_TOTAL,
873                     AggregationType.SUM,
874                     RECORD_TYPE_NUTRITION,
875                     Mass.class);
876 
877     /**
878      * Metric identifier to get total energy using aggregate APIs in {@link HealthConnectManager}
879      */
880     @NonNull
881     public static final AggregationType<Energy> ENERGY_TOTAL =
882             new AggregationType<>(
883                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_ENERGY_TOTAL,
884                     AggregationType.SUM,
885                     RECORD_TYPE_NUTRITION,
886                     Energy.class);
887 
888     /**
889      * Metric identifier to get total energy from fat using aggregate APIs in {@link
890      * HealthConnectManager}
891      */
892     @NonNull
893     public static final AggregationType<Energy> ENERGY_FROM_FAT_TOTAL =
894             new AggregationType<>(
895                     AggregationType.AggregationTypeIdentifier
896                             .NUTRITION_RECORD_ENERGY_FROM_FAT_TOTAL,
897                     AggregationType.SUM,
898                     RECORD_TYPE_NUTRITION,
899                     Energy.class);
900 
901     /**
902      * Metric identifier to get total folate using aggregate APIs in {@link HealthConnectManager}
903      */
904     @NonNull
905     public static final AggregationType<Mass> FOLATE_TOTAL =
906             new AggregationType<>(
907                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_FOLATE_TOTAL,
908                     AggregationType.SUM,
909                     RECORD_TYPE_NUTRITION,
910                     Mass.class);
911 
912     /**
913      * Metric identifier to get total folic acid using aggregate APIs in {@link
914      * HealthConnectManager}
915      */
916     @NonNull
917     public static final AggregationType<Mass> FOLIC_ACID_TOTAL =
918             new AggregationType<>(
919                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_FOLIC_ACID_TOTAL,
920                     AggregationType.SUM,
921                     RECORD_TYPE_NUTRITION,
922                     Mass.class);
923 
924     /**
925      * Metric identifier to get total iodine using aggregate APIs in {@link HealthConnectManager}
926      */
927     @NonNull
928     public static final AggregationType<Mass> IODINE_TOTAL =
929             new AggregationType<>(
930                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_IODINE_TOTAL,
931                     AggregationType.SUM,
932                     RECORD_TYPE_NUTRITION,
933                     Mass.class);
934 
935     /** Metric identifier to get total iron using aggregate APIs in {@link HealthConnectManager} */
936     @NonNull
937     public static final AggregationType<Mass> IRON_TOTAL =
938             new AggregationType<>(
939                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_IRON_TOTAL,
940                     AggregationType.SUM,
941                     RECORD_TYPE_NUTRITION,
942                     Mass.class);
943 
944     /**
945      * Metric identifier to get total magnesium using aggregate APIs in {@link HealthConnectManager}
946      */
947     @NonNull
948     public static final AggregationType<Mass> MAGNESIUM_TOTAL =
949             new AggregationType<>(
950                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_MAGNESIUM_TOTAL,
951                     AggregationType.SUM,
952                     RECORD_TYPE_NUTRITION,
953                     Mass.class);
954 
955     /**
956      * Metric identifier to get total manganese using aggregate APIs in {@link HealthConnectManager}
957      */
958     @NonNull
959     public static final AggregationType<Mass> MANGANESE_TOTAL =
960             new AggregationType<>(
961                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_MANGANESE_TOTAL,
962                     AggregationType.SUM,
963                     RECORD_TYPE_NUTRITION,
964                     Mass.class);
965 
966     /**
967      * Metric identifier to get total molybdenum using aggregate APIs in {@link
968      * HealthConnectManager}
969      */
970     @NonNull
971     public static final AggregationType<Mass> MOLYBDENUM_TOTAL =
972             new AggregationType<>(
973                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_MOLYBDENUM_TOTAL,
974                     AggregationType.SUM,
975                     RECORD_TYPE_NUTRITION,
976                     Mass.class);
977 
978     /**
979      * Metric identifier to get total monounsaturated fat using aggregate APIs in {@link
980      * HealthConnectManager}
981      */
982     @NonNull
983     public static final AggregationType<Mass> MONOUNSATURATED_FAT_TOTAL =
984             new AggregationType<>(
985                     AggregationType.AggregationTypeIdentifier
986                             .NUTRITION_RECORD_MONOUNSATURATED_FAT_TOTAL,
987                     AggregationType.SUM,
988                     RECORD_TYPE_NUTRITION,
989                     Mass.class);
990 
991     /**
992      * Metric identifier to get total niacin using aggregate APIs in {@link HealthConnectManager}
993      */
994     @NonNull
995     public static final AggregationType<Mass> NIACIN_TOTAL =
996             new AggregationType<>(
997                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_NIACIN_TOTAL,
998                     AggregationType.SUM,
999                     RECORD_TYPE_NUTRITION,
1000                     Mass.class);
1001 
1002     /**
1003      * Metric identifier to get total pantothenic acid fat using aggregate APIs in {@link
1004      * HealthConnectManager}
1005      */
1006     @NonNull
1007     public static final AggregationType<Mass> PANTOTHENIC_ACID_TOTAL =
1008             new AggregationType<>(
1009                     AggregationType.AggregationTypeIdentifier
1010                             .NUTRITION_RECORD_PANTOTHENIC_ACID_TOTAL,
1011                     AggregationType.SUM,
1012                     RECORD_TYPE_NUTRITION,
1013                     Mass.class);
1014 
1015     /**
1016      * Metric identifier to get total phosphorus fat using aggregate APIs in {@link
1017      * HealthConnectManager}
1018      */
1019     @NonNull
1020     public static final AggregationType<Mass> PHOSPHORUS_TOTAL =
1021             new AggregationType<>(
1022                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_PHOSPHORUS_TOTAL,
1023                     AggregationType.SUM,
1024                     RECORD_TYPE_NUTRITION,
1025                     Mass.class);
1026 
1027     /**
1028      * Metric identifier to get total polyunsaturated fat using aggregate APIs in {@link
1029      * HealthConnectManager}
1030      */
1031     @NonNull
1032     public static final AggregationType<Mass> POLYUNSATURATED_FAT_TOTAL =
1033             new AggregationType<>(
1034                     AggregationType.AggregationTypeIdentifier
1035                             .NUTRITION_RECORD_POLYUNSATURATED_FAT_TOTAL,
1036                     AggregationType.SUM,
1037                     RECORD_TYPE_NUTRITION,
1038                     Mass.class);
1039 
1040     /**
1041      * Metric identifier to get total potassium using aggregate APIs in {@link HealthConnectManager}
1042      */
1043     @NonNull
1044     public static final AggregationType<Mass> POTASSIUM_TOTAL =
1045             new AggregationType<>(
1046                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_POTASSIUM_TOTAL,
1047                     AggregationType.SUM,
1048                     RECORD_TYPE_NUTRITION,
1049                     Mass.class);
1050 
1051     /**
1052      * Metric identifier to get total protein using aggregate APIs in {@link HealthConnectManager}
1053      */
1054     @NonNull
1055     public static final AggregationType<Mass> PROTEIN_TOTAL =
1056             new AggregationType<>(
1057                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_PROTEIN_TOTAL,
1058                     AggregationType.SUM,
1059                     RECORD_TYPE_NUTRITION,
1060                     Mass.class);
1061 
1062     /**
1063      * Metric identifier to get total riboflavin using aggregate APIs in {@link
1064      * HealthConnectManager}
1065      */
1066     @NonNull
1067     public static final AggregationType<Mass> RIBOFLAVIN_TOTAL =
1068             new AggregationType<>(
1069                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_RIBOFLAVIN_TOTAL,
1070                     AggregationType.SUM,
1071                     RECORD_TYPE_NUTRITION,
1072                     Mass.class);
1073 
1074     /**
1075      * Metric identifier to get total saturated fat using aggregate APIs in {@link
1076      * HealthConnectManager}
1077      */
1078     @NonNull
1079     public static final AggregationType<Mass> SATURATED_FAT_TOTAL =
1080             new AggregationType<>(
1081                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_SATURATED_FAT_TOTAL,
1082                     AggregationType.SUM,
1083                     RECORD_TYPE_NUTRITION,
1084                     Mass.class);
1085 
1086     /**
1087      * Metric identifier to get total selenium using aggregate APIs in {@link HealthConnectManager}
1088      */
1089     @NonNull
1090     public static final AggregationType<Mass> SELENIUM_TOTAL =
1091             new AggregationType<>(
1092                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_SELENIUM_TOTAL,
1093                     AggregationType.SUM,
1094                     RECORD_TYPE_NUTRITION,
1095                     Mass.class);
1096 
1097     /**
1098      * Metric identifier to get total sodium using aggregate APIs in {@link HealthConnectManager}
1099      */
1100     @NonNull
1101     public static final AggregationType<Mass> SODIUM_TOTAL =
1102             new AggregationType<>(
1103                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_SODIUM_TOTAL,
1104                     AggregationType.SUM,
1105                     RECORD_TYPE_NUTRITION,
1106                     Mass.class);
1107 
1108     /** Metric identifier to get total sugar using aggregate APIs in {@link HealthConnectManager} */
1109     @NonNull
1110     public static final AggregationType<Mass> SUGAR_TOTAL =
1111             new AggregationType<>(
1112                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_SUGAR_TOTAL,
1113                     AggregationType.SUM,
1114                     RECORD_TYPE_NUTRITION,
1115                     Mass.class);
1116 
1117     /**
1118      * Metric identifier to get total thiamin using aggregate APIs in {@link HealthConnectManager}
1119      */
1120     @NonNull
1121     public static final AggregationType<Mass> THIAMIN_TOTAL =
1122             new AggregationType<>(
1123                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_THIAMIN_TOTAL,
1124                     AggregationType.SUM,
1125                     RECORD_TYPE_NUTRITION,
1126                     Mass.class);
1127 
1128     /**
1129      * Metric identifier to get total carbohydrate using aggregate APIs in {@link
1130      * HealthConnectManager}
1131      */
1132     @NonNull
1133     public static final AggregationType<Mass> TOTAL_CARBOHYDRATE_TOTAL =
1134             new AggregationType<>(
1135                     AggregationType.AggregationTypeIdentifier
1136                             .NUTRITION_RECORD_TOTAL_CARBOHYDRATE_TOTAL,
1137                     AggregationType.SUM,
1138                     RECORD_TYPE_NUTRITION,
1139                     Mass.class);
1140 
1141     /** Metric identifier to get total fat using aggregate APIs in {@link HealthConnectManager} */
1142     @NonNull
1143     public static final AggregationType<Mass> TOTAL_FAT_TOTAL =
1144             new AggregationType<>(
1145                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_TOTAL_FAT_TOTAL,
1146                     AggregationType.SUM,
1147                     RECORD_TYPE_NUTRITION,
1148                     Mass.class);
1149 
1150     /**
1151      * Metric identifier to get total trans fat using aggregate APIs in {@link HealthConnectManager}
1152      */
1153     @NonNull
1154     public static final AggregationType<Mass> TRANS_FAT_TOTAL =
1155             new AggregationType<>(
1156                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_TRANS_FAT_TOTAL,
1157                     AggregationType.SUM,
1158                     RECORD_TYPE_NUTRITION,
1159                     Mass.class);
1160 
1161     /**
1162      * Metric identifier to get total unsaturated fat using aggregate APIs in {@link
1163      * HealthConnectManager}
1164      */
1165     @NonNull
1166     public static final AggregationType<Mass> UNSATURATED_FAT_TOTAL =
1167             new AggregationType<>(
1168                     AggregationType.AggregationTypeIdentifier
1169                             .NUTRITION_RECORD_UNSATURATED_FAT_TOTAL,
1170                     AggregationType.SUM,
1171                     RECORD_TYPE_NUTRITION,
1172                     Mass.class);
1173 
1174     /**
1175      * Metric identifier to get total Vitamin A using aggregate APIs in {@link HealthConnectManager}
1176      */
1177     @NonNull
1178     public static final AggregationType<Mass> VITAMIN_A_TOTAL =
1179             new AggregationType<>(
1180                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_A_TOTAL,
1181                     AggregationType.SUM,
1182                     RECORD_TYPE_NUTRITION,
1183                     Mass.class);
1184 
1185     /**
1186      * Metric identifier to get total Vitamin B12 using aggregate APIs in {@link
1187      * HealthConnectManager}
1188      */
1189     @NonNull
1190     public static final AggregationType<Mass> VITAMIN_B12_TOTAL =
1191             new AggregationType<>(
1192                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_B12_TOTAL,
1193                     AggregationType.SUM,
1194                     RECORD_TYPE_NUTRITION,
1195                     Mass.class);
1196 
1197     /**
1198      * Metric identifier to get total Vitamin B6 using aggregate APIs in {@link
1199      * HealthConnectManager}
1200      */
1201     @NonNull
1202     public static final AggregationType<Mass> VITAMIN_B6_TOTAL =
1203             new AggregationType<>(
1204                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_B6_TOTAL,
1205                     AggregationType.SUM,
1206                     RECORD_TYPE_NUTRITION,
1207                     Mass.class);
1208 
1209     /**
1210      * Metric identifier to get total Vitamin C using aggregate APIs in {@link HealthConnectManager}
1211      */
1212     @NonNull
1213     public static final AggregationType<Mass> VITAMIN_C_TOTAL =
1214             new AggregationType<>(
1215                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_C_TOTAL,
1216                     AggregationType.SUM,
1217                     RECORD_TYPE_NUTRITION,
1218                     Mass.class);
1219 
1220     /**
1221      * Metric identifier to get total Vitamin D using aggregate APIs in {@link HealthConnectManager}
1222      */
1223     @NonNull
1224     public static final AggregationType<Mass> VITAMIN_D_TOTAL =
1225             new AggregationType<>(
1226                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_D_TOTAL,
1227                     AggregationType.SUM,
1228                     RECORD_TYPE_NUTRITION,
1229                     Mass.class);
1230 
1231     /**
1232      * Metric identifier to get total Vitamin E using aggregate APIs in {@link HealthConnectManager}
1233      */
1234     @NonNull
1235     public static final AggregationType<Mass> VITAMIN_E_TOTAL =
1236             new AggregationType<>(
1237                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_E_TOTAL,
1238                     AggregationType.SUM,
1239                     RECORD_TYPE_NUTRITION,
1240                     Mass.class);
1241 
1242     /**
1243      * Metric identifier to get total Vitamin K using aggregate APIs in {@link HealthConnectManager}
1244      */
1245     @NonNull
1246     public static final AggregationType<Mass> VITAMIN_K_TOTAL =
1247             new AggregationType<>(
1248                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_VITAMIN_K_TOTAL,
1249                     AggregationType.SUM,
1250                     RECORD_TYPE_NUTRITION,
1251                     Mass.class);
1252 
1253     /** Metric identifier to get total Zinc using aggregate APIs in {@link HealthConnectManager} */
1254     @NonNull
1255     public static final AggregationType<Mass> ZINC_TOTAL =
1256             new AggregationType<>(
1257                     AggregationType.AggregationTypeIdentifier.NUTRITION_RECORD_ZINC_TOTAL,
1258                     AggregationType.SUM,
1259                     RECORD_TYPE_NUTRITION,
1260                     Mass.class);
1261 
1262     private final int mMealType;
1263     private final Mass mUnsaturatedFat;
1264     private final Mass mPotassium;
1265     private final Mass mThiamin;
1266     private final Mass mTransFat;
1267     private final Mass mManganese;
1268     private final Energy mEnergyFromFat;
1269     private final Mass mCaffeine;
1270     private final Mass mDietaryFiber;
1271     private final Mass mSelenium;
1272     private final Mass mVitaminB6;
1273     private final Mass mProtein;
1274     private final Mass mChloride;
1275     private final Mass mCholesterol;
1276     private final Mass mCopper;
1277     private final Mass mIodine;
1278     private final Mass mVitaminB12;
1279     private final Mass mZinc;
1280     private final Mass mRiboflavin;
1281     private final Energy mEnergy;
1282     private final Mass mMolybdenum;
1283     private final Mass mPhosphorus;
1284     private final Mass mChromium;
1285     private final Mass mTotalFat;
1286     private final Mass mCalcium;
1287     private final Mass mVitaminC;
1288     private final Mass mVitaminE;
1289     private final Mass mBiotin;
1290     private final Mass mVitaminD;
1291     private final Mass mNiacin;
1292     private final Mass mMagnesium;
1293     private final Mass mTotalCarbohydrate;
1294     private final Mass mVitaminK;
1295     private final Mass mPolyunsaturatedFat;
1296     private final Mass mSaturatedFat;
1297     private final Mass mSodium;
1298     private final Mass mFolate;
1299     private final Mass mMonounsaturatedFat;
1300     private final Mass mPantothenicAcid;
1301     private final String mMealName;
1302     private final Mass mIron;
1303     private final Mass mVitaminA;
1304     private final Mass mFolicAcid;
1305     private final Mass mSugar;
1306 
1307     /**
1308      * @param metadata Metadata to be associated with the record. See {@link Metadata}.
1309      * @param startTime Start time of this activity
1310      * @param startZoneOffset Zone offset of the user when the activity started
1311      * @param endTime End time of this activity
1312      * @param endZoneOffset Zone offset of the user when the activity finished
1313      * @param unsaturatedFat UnsaturatedFat of this activity in {@link Mass} unit. Optional field.
1314      * @param potassium Potassium of this activity in {@link Mass} unit. Optional field.
1315      * @param thiamin Thiamin of this activity in {@link Mass} unit. Optional field.
1316      * @param mealType Type of meal related to the nutrients consumed. Optional, enum field. Allowed
1317      *     values: {@link MealType.MealTypes}
1318      * @param transFat TransFat of this activity in {@link Mass} unit. Optional field.
1319      * @param manganese Manganese of this activity in {@link Mass} unit. Optional field.
1320      * @param energyFromFat EnergyFromFat of this activity in {@link Energy} unit. Optional field.
1321      * @param caffeine Caffeine of this activity in {@link Mass} unit. Optional field.
1322      * @param dietaryFiber DietaryFiber of this activity in {@link Mass} unit. Optional field.
1323      * @param selenium Selenium of this activity in {@link Mass} unit. Optional field.
1324      * @param vitaminB6 VitaminB6 of this activity in {@link Mass} unit. Optional field.
1325      * @param protein Protein of this activity in {@link Mass} unit. Optional field.
1326      * @param chloride Chloride of this activity in {@link Mass} unit. Optional field.
1327      * @param cholesterol Cholesterol of this activity in {@link Mass} unit. Optional field.
1328      * @param copper Copper of this activity in {@link Mass} unit. Optional field.
1329      * @param iodine Iodine of this activity in {@link Mass} unit. Optional field.
1330      * @param vitaminB12 VitaminB12 of this activity in {@link Mass} unit. Optional field.
1331      * @param zinc Zinc of this activity in {@link Mass} unit. Optional field.
1332      * @param riboflavin Riboflavin of this activity in {@link Mass} unit. Optional field.
1333      * @param energy Energy of this activity in {@link Energy} unit. Optional field.
1334      * @param molybdenum Molybdenum of this activity in {@link Mass} unit. Optional field.
1335      * @param phosphorus Phosphorus of this activity in {@link Mass} unit. Optional field.
1336      * @param chromium Chromium of this activity in {@link Mass} unit. Optional field.
1337      * @param totalFat TotalFat of this activity in {@link Mass} unit. Optional field.
1338      * @param calcium Calcium of this activity in {@link Mass} unit. Optional field.
1339      * @param vitaminC VitaminC of this activity in {@link Mass} unit. Optional field.
1340      * @param vitaminE VitaminE of this activity in {@link Mass} unit. Optional field.
1341      * @param biotin Biotin of this activity in {@link Mass} unit. Optional field.
1342      * @param vitaminD VitaminD of this activity in {@link Mass} unit. Optional field.
1343      * @param niacin Niacin of this activity in {@link Mass} unit. Optional field.
1344      * @param magnesium Magnesium of this activity in {@link Mass} unit. Optional field.
1345      * @param totalCarbohydrate TotalCarbohydrate of this activity in {@link Mass} unit. Optional
1346      *     field.
1347      * @param vitaminK VitaminK of this activity in {@link Mass} unit. Optional field.
1348      * @param polyunsaturatedFat PolyunsaturatedFat of this activity in {@link Mass} unit. Optional
1349      *     field.
1350      * @param saturatedFat SaturatedFat of this activity in {@link Mass} unit. Optional field.
1351      * @param sodium Sodium of this activity in {@link Mass} unit. Optional field.
1352      * @param folate Folate of this activity in {@link Mass} unit. Optional field.
1353      * @param monounsaturatedFat MonounsaturatedFat of this activity in {@link Mass} unit. Optional
1354      *     field.
1355      * @param pantothenicAcid PantothenicAcid of this activity in {@link Mass} unit. Optional field.
1356      * @param mealName Name of the meal. Optional field.
1357      * @param iron Iron of this activity in {@link Mass} unit. Optional field.
1358      * @param vitaminA VitaminA of this activity in {@link Mass} unit. Optional field.
1359      * @param folicAcid FolicAcid of this activity in {@link Mass} unit. Optional field.
1360      * @param sugar Sugar of this activity in {@link Mass} unit. Optional field.
1361      * @param skipValidation Boolean flag to skip validation of record values.
1362      */
1363     @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
NutritionRecord( @onNull Metadata metadata, @NonNull Instant startTime, @NonNull ZoneOffset startZoneOffset, @NonNull Instant endTime, @NonNull ZoneOffset endZoneOffset, @Nullable Mass unsaturatedFat, @Nullable Mass potassium, @Nullable Mass thiamin, @MealType.MealTypes int mealType, @Nullable Mass transFat, @Nullable Mass manganese, @Nullable Energy energyFromFat, @Nullable Mass caffeine, @Nullable Mass dietaryFiber, @Nullable Mass selenium, @Nullable Mass vitaminB6, @Nullable Mass protein, @Nullable Mass chloride, @Nullable Mass cholesterol, @Nullable Mass copper, @Nullable Mass iodine, @Nullable Mass vitaminB12, @Nullable Mass zinc, @Nullable Mass riboflavin, @Nullable Energy energy, @Nullable Mass molybdenum, @Nullable Mass phosphorus, @Nullable Mass chromium, @Nullable Mass totalFat, @Nullable Mass calcium, @Nullable Mass vitaminC, @Nullable Mass vitaminE, @Nullable Mass biotin, @Nullable Mass vitaminD, @Nullable Mass niacin, @Nullable Mass magnesium, @Nullable Mass totalCarbohydrate, @Nullable Mass vitaminK, @Nullable Mass polyunsaturatedFat, @Nullable Mass saturatedFat, @Nullable Mass sodium, @Nullable Mass folate, @Nullable Mass monounsaturatedFat, @Nullable Mass pantothenicAcid, @Nullable String mealName, @Nullable Mass iron, @Nullable Mass vitaminA, @Nullable Mass folicAcid, @Nullable Mass sugar, boolean skipValidation)1364     private NutritionRecord(
1365             @NonNull Metadata metadata,
1366             @NonNull Instant startTime,
1367             @NonNull ZoneOffset startZoneOffset,
1368             @NonNull Instant endTime,
1369             @NonNull ZoneOffset endZoneOffset,
1370             @Nullable Mass unsaturatedFat,
1371             @Nullable Mass potassium,
1372             @Nullable Mass thiamin,
1373             @MealType.MealTypes int mealType,
1374             @Nullable Mass transFat,
1375             @Nullable Mass manganese,
1376             @Nullable Energy energyFromFat,
1377             @Nullable Mass caffeine,
1378             @Nullable Mass dietaryFiber,
1379             @Nullable Mass selenium,
1380             @Nullable Mass vitaminB6,
1381             @Nullable Mass protein,
1382             @Nullable Mass chloride,
1383             @Nullable Mass cholesterol,
1384             @Nullable Mass copper,
1385             @Nullable Mass iodine,
1386             @Nullable Mass vitaminB12,
1387             @Nullable Mass zinc,
1388             @Nullable Mass riboflavin,
1389             @Nullable Energy energy,
1390             @Nullable Mass molybdenum,
1391             @Nullable Mass phosphorus,
1392             @Nullable Mass chromium,
1393             @Nullable Mass totalFat,
1394             @Nullable Mass calcium,
1395             @Nullable Mass vitaminC,
1396             @Nullable Mass vitaminE,
1397             @Nullable Mass biotin,
1398             @Nullable Mass vitaminD,
1399             @Nullable Mass niacin,
1400             @Nullable Mass magnesium,
1401             @Nullable Mass totalCarbohydrate,
1402             @Nullable Mass vitaminK,
1403             @Nullable Mass polyunsaturatedFat,
1404             @Nullable Mass saturatedFat,
1405             @Nullable Mass sodium,
1406             @Nullable Mass folate,
1407             @Nullable Mass monounsaturatedFat,
1408             @Nullable Mass pantothenicAcid,
1409             @Nullable String mealName,
1410             @Nullable Mass iron,
1411             @Nullable Mass vitaminA,
1412             @Nullable Mass folicAcid,
1413             @Nullable Mass sugar,
1414             boolean skipValidation) {
1415         super(
1416                 metadata,
1417                 startTime,
1418                 startZoneOffset,
1419                 endTime,
1420                 endZoneOffset,
1421                 skipValidation,
1422                 /* enforceFutureTimeRestrictions= */ true);
1423         validateIntDefValue(mealType, MealType.VALID_TYPES, MealType.class.getSimpleName());
1424         if (!skipValidation) {
1425             requireInRangeIfExists(unsaturatedFat, MASS_0_0, MASS_100000, "unsaturatedFat");
1426             requireInRangeIfExists(potassium, MASS_0_0, MASS_100, "potassium");
1427             requireInRangeIfExists(thiamin, MASS_0_0, MASS_100, "thiamin");
1428             requireInRangeIfExists(transFat, MASS_0_0, MASS_100000, "transFat");
1429             requireInRangeIfExists(manganese, MASS_0_0, MASS_100, "manganese");
1430             requireInRangeIfExists(
1431                     energyFromFat, ENERGY_0_0, Energy.fromCalories(100000000.0), "energyFromFat");
1432             requireInRangeIfExists(caffeine, MASS_0_0, MASS_100, "caffeine");
1433             requireInRangeIfExists(dietaryFiber, MASS_0_0, MASS_100000, "dietaryFiber");
1434             requireInRangeIfExists(selenium, MASS_0_0, MASS_100, "selenium");
1435             requireInRangeIfExists(vitaminB6, MASS_0_0, MASS_100, "vitaminB6");
1436             requireInRangeIfExists(protein, MASS_0_0, MASS_100000, "protein");
1437             requireInRangeIfExists(chloride, MASS_0_0, MASS_100, "chloride");
1438             requireInRangeIfExists(cholesterol, MASS_0_0, MASS_100, "cholesterol");
1439             requireInRangeIfExists(copper, MASS_0_0, MASS_100, "copper");
1440             requireInRangeIfExists(iodine, MASS_0_0, MASS_100, "iodine");
1441             requireInRangeIfExists(vitaminB12, MASS_0_0, MASS_100, "vitaminB12");
1442             requireInRangeIfExists(zinc, MASS_0_0, MASS_100, "zinc");
1443             requireInRangeIfExists(riboflavin, MASS_0_0, MASS_100, "riboflavin");
1444             requireInRangeIfExists(energy, ENERGY_0_0, Energy.fromCalories(100000000.0), "energy");
1445             requireInRangeIfExists(molybdenum, MASS_0_0, MASS_100, "molybdenum");
1446             requireInRangeIfExists(phosphorus, MASS_0_0, MASS_100, "phosphorus");
1447             requireInRangeIfExists(chromium, MASS_0_0, MASS_100, "chromium");
1448             requireInRangeIfExists(totalFat, MASS_0_0, MASS_100000, "totalFat");
1449             requireInRangeIfExists(calcium, MASS_0_0, MASS_100, "calcium");
1450             requireInRangeIfExists(vitaminC, MASS_0_0, MASS_100, "vitaminC");
1451             requireInRangeIfExists(vitaminE, MASS_0_0, MASS_100, "vitaminE");
1452             requireInRangeIfExists(biotin, MASS_0_0, MASS_100, "biotin");
1453             requireInRangeIfExists(vitaminD, MASS_0_0, MASS_100, "vitaminD");
1454             requireInRangeIfExists(niacin, MASS_0_0, MASS_100, "niacin");
1455             requireInRangeIfExists(magnesium, MASS_0_0, MASS_100, "magnesium");
1456             requireInRangeIfExists(totalCarbohydrate, MASS_0_0, MASS_100000, "totalCarbohydrate");
1457             requireInRangeIfExists(vitaminK, MASS_0_0, MASS_100, "vitaminK");
1458             requireInRangeIfExists(polyunsaturatedFat, MASS_0_0, MASS_100000, "polyunsaturatedFat");
1459             requireInRangeIfExists(saturatedFat, MASS_0_0, MASS_100000, "saturatedFat");
1460             requireInRangeIfExists(sodium, MASS_0_0, MASS_100, "sodium");
1461             requireInRangeIfExists(folate, MASS_0_0, MASS_100, "folate");
1462             requireInRangeIfExists(monounsaturatedFat, MASS_0_0, MASS_100000, "monounsaturatedFat");
1463             requireInRangeIfExists(pantothenicAcid, MASS_0_0, MASS_100, "pantothenicAcid");
1464             requireInRangeIfExists(iron, MASS_0_0, MASS_100, "iron");
1465             requireInRangeIfExists(vitaminA, MASS_0_0, MASS_100, "vitaminA");
1466             requireInRangeIfExists(folicAcid, MASS_0_0, MASS_100, "folicAcid");
1467             requireInRangeIfExists(sugar, MASS_0_0, MASS_100000, "sugar");
1468         }
1469         mUnsaturatedFat = unsaturatedFat;
1470         mPotassium = potassium;
1471         mThiamin = thiamin;
1472         mMealType = mealType;
1473         mTransFat = transFat;
1474         mManganese = manganese;
1475         mEnergyFromFat = energyFromFat;
1476         mCaffeine = caffeine;
1477         mDietaryFiber = dietaryFiber;
1478         mSelenium = selenium;
1479         mVitaminB6 = vitaminB6;
1480         mProtein = protein;
1481         mChloride = chloride;
1482         mCholesterol = cholesterol;
1483         mCopper = copper;
1484         mIodine = iodine;
1485         mVitaminB12 = vitaminB12;
1486         mZinc = zinc;
1487         mRiboflavin = riboflavin;
1488         mEnergy = energy;
1489         mMolybdenum = molybdenum;
1490         mPhosphorus = phosphorus;
1491         mChromium = chromium;
1492         mTotalFat = totalFat;
1493         mCalcium = calcium;
1494         mVitaminC = vitaminC;
1495         mVitaminE = vitaminE;
1496         mBiotin = biotin;
1497         mVitaminD = vitaminD;
1498         mNiacin = niacin;
1499         mMagnesium = magnesium;
1500         mTotalCarbohydrate = totalCarbohydrate;
1501         mVitaminK = vitaminK;
1502         mPolyunsaturatedFat = polyunsaturatedFat;
1503         mSaturatedFat = saturatedFat;
1504         mSodium = sodium;
1505         mFolate = folate;
1506         mMonounsaturatedFat = monounsaturatedFat;
1507         mPantothenicAcid = pantothenicAcid;
1508         mMealName = mealName;
1509         mIron = iron;
1510         mVitaminA = vitaminA;
1511         mFolicAcid = folicAcid;
1512         mSugar = sugar;
1513     }
1514 
1515     /**
1516      * @return mealType
1517      */
1518     @MealType.MealTypes
getMealType()1519     public int getMealType() {
1520         return mMealType;
1521     }
1522 
1523     /**
1524      * @return unsaturatedFat
1525      */
1526     @Nullable
getUnsaturatedFat()1527     public Mass getUnsaturatedFat() {
1528         return mUnsaturatedFat;
1529     }
1530 
1531     /**
1532      * @return potassium
1533      */
1534     @Nullable
getPotassium()1535     public Mass getPotassium() {
1536         return mPotassium;
1537     }
1538 
1539     /**
1540      * @return thiamin
1541      */
1542     @Nullable
getThiamin()1543     public Mass getThiamin() {
1544         return mThiamin;
1545     }
1546 
1547     /**
1548      * @return transFat in {@link Mass} unit.
1549      */
1550     @Nullable
getTransFat()1551     public Mass getTransFat() {
1552         return mTransFat;
1553     }
1554 
1555     /**
1556      * @return manganese in {@link Mass} unit.
1557      */
1558     @Nullable
getManganese()1559     public Mass getManganese() {
1560         return mManganese;
1561     }
1562 
1563     /**
1564      * @return energyFromFat in {@link Energy} unit.
1565      */
1566     @Nullable
getEnergyFromFat()1567     public Energy getEnergyFromFat() {
1568         return mEnergyFromFat;
1569     }
1570 
1571     /**
1572      * @return caffeine in {@link Mass} unit.
1573      */
1574     @Nullable
getCaffeine()1575     public Mass getCaffeine() {
1576         return mCaffeine;
1577     }
1578 
1579     /**
1580      * @return dietaryFiber in {@link Mass} unit.
1581      */
1582     @Nullable
getDietaryFiber()1583     public Mass getDietaryFiber() {
1584         return mDietaryFiber;
1585     }
1586 
1587     /**
1588      * @return selenium in {@link Mass} unit.
1589      */
1590     @Nullable
getSelenium()1591     public Mass getSelenium() {
1592         return mSelenium;
1593     }
1594 
1595     /**
1596      * @return vitaminB6 in {@link Mass} unit.
1597      */
1598     @Nullable
getVitaminB6()1599     public Mass getVitaminB6() {
1600         return mVitaminB6;
1601     }
1602 
1603     /**
1604      * @return protein in {@link Mass} unit.
1605      */
1606     @Nullable
getProtein()1607     public Mass getProtein() {
1608         return mProtein;
1609     }
1610 
1611     /**
1612      * @return chloride in {@link Mass} unit.
1613      */
1614     @Nullable
getChloride()1615     public Mass getChloride() {
1616         return mChloride;
1617     }
1618 
1619     /**
1620      * @return cholesterol in {@link Mass} unit.
1621      */
1622     @Nullable
getCholesterol()1623     public Mass getCholesterol() {
1624         return mCholesterol;
1625     }
1626 
1627     /**
1628      * @return copper in {@link Mass} unit.
1629      */
1630     @Nullable
getCopper()1631     public Mass getCopper() {
1632         return mCopper;
1633     }
1634 
1635     /**
1636      * @return iodine in {@link Mass} unit.
1637      */
1638     @Nullable
getIodine()1639     public Mass getIodine() {
1640         return mIodine;
1641     }
1642 
1643     /**
1644      * @return vitaminB12 in {@link Mass} unit.
1645      */
1646     @Nullable
getVitaminB12()1647     public Mass getVitaminB12() {
1648         return mVitaminB12;
1649     }
1650 
1651     /**
1652      * @return zinc in {@link Mass} unit.
1653      */
1654     @Nullable
getZinc()1655     public Mass getZinc() {
1656         return mZinc;
1657     }
1658 
1659     /**
1660      * @return riboflavin in {@link Mass} unit.
1661      */
1662     @Nullable
getRiboflavin()1663     public Mass getRiboflavin() {
1664         return mRiboflavin;
1665     }
1666 
1667     /**
1668      * @return energy in {@link Energy} unit.
1669      */
1670     @Nullable
getEnergy()1671     public Energy getEnergy() {
1672         return mEnergy;
1673     }
1674 
1675     /**
1676      * @return molybdenum in {@link Mass} unit.
1677      */
1678     @Nullable
getMolybdenum()1679     public Mass getMolybdenum() {
1680         return mMolybdenum;
1681     }
1682 
1683     /**
1684      * @return phosphorus in {@link Mass} unit.
1685      */
1686     @Nullable
getPhosphorus()1687     public Mass getPhosphorus() {
1688         return mPhosphorus;
1689     }
1690 
1691     /**
1692      * @return chromium in {@link Mass} unit.
1693      */
1694     @Nullable
getChromium()1695     public Mass getChromium() {
1696         return mChromium;
1697     }
1698 
1699     /**
1700      * @return totalFat in {@link Mass} unit.
1701      */
1702     @Nullable
getTotalFat()1703     public Mass getTotalFat() {
1704         return mTotalFat;
1705     }
1706 
1707     /**
1708      * @return calcium in {@link Mass} unit.
1709      */
1710     @Nullable
getCalcium()1711     public Mass getCalcium() {
1712         return mCalcium;
1713     }
1714 
1715     /**
1716      * @return vitaminC in {@link Mass} unit.
1717      */
1718     @Nullable
getVitaminC()1719     public Mass getVitaminC() {
1720         return mVitaminC;
1721     }
1722 
1723     /**
1724      * @return vitaminE in {@link Mass} unit.
1725      */
1726     @Nullable
getVitaminE()1727     public Mass getVitaminE() {
1728         return mVitaminE;
1729     }
1730 
1731     /**
1732      * @return biotin in {@link Mass} unit.
1733      */
1734     @Nullable
getBiotin()1735     public Mass getBiotin() {
1736         return mBiotin;
1737     }
1738 
1739     /**
1740      * @return vitaminD in {@link Mass} unit.
1741      */
1742     @Nullable
getVitaminD()1743     public Mass getVitaminD() {
1744         return mVitaminD;
1745     }
1746 
1747     /**
1748      * @return niacin in {@link Mass} unit.
1749      */
1750     @Nullable
getNiacin()1751     public Mass getNiacin() {
1752         return mNiacin;
1753     }
1754 
1755     /**
1756      * @return magnesium in {@link Mass} unit.
1757      */
1758     @Nullable
getMagnesium()1759     public Mass getMagnesium() {
1760         return mMagnesium;
1761     }
1762 
1763     /**
1764      * @return totalCarbohydrate in {@link Mass} unit.
1765      */
1766     @Nullable
getTotalCarbohydrate()1767     public Mass getTotalCarbohydrate() {
1768         return mTotalCarbohydrate;
1769     }
1770 
1771     /**
1772      * @return vitaminK in {@link Mass} unit.
1773      */
1774     @Nullable
getVitaminK()1775     public Mass getVitaminK() {
1776         return mVitaminK;
1777     }
1778 
1779     /**
1780      * @return polyunsaturatedFat in {@link Mass} unit.
1781      */
1782     @Nullable
getPolyunsaturatedFat()1783     public Mass getPolyunsaturatedFat() {
1784         return mPolyunsaturatedFat;
1785     }
1786 
1787     /**
1788      * @return saturatedFat in {@link Mass} unit.
1789      */
1790     @Nullable
getSaturatedFat()1791     public Mass getSaturatedFat() {
1792         return mSaturatedFat;
1793     }
1794 
1795     /**
1796      * @return sodium in {@link Mass} unit.
1797      */
1798     @Nullable
getSodium()1799     public Mass getSodium() {
1800         return mSodium;
1801     }
1802 
1803     /**
1804      * @return folate in {@link Mass} unit.
1805      */
1806     @Nullable
getFolate()1807     public Mass getFolate() {
1808         return mFolate;
1809     }
1810 
1811     /**
1812      * @return monounsaturatedFat in {@link Mass} unit.
1813      */
1814     @Nullable
getMonounsaturatedFat()1815     public Mass getMonounsaturatedFat() {
1816         return mMonounsaturatedFat;
1817     }
1818 
1819     /**
1820      * @return pantothenicAcid in {@link Mass} unit.
1821      */
1822     @Nullable
getPantothenicAcid()1823     public Mass getPantothenicAcid() {
1824         return mPantothenicAcid;
1825     }
1826 
1827     /**
1828      * @return the meal name.
1829      */
1830     @Nullable
getMealName()1831     public String getMealName() {
1832         return mMealName;
1833     }
1834 
1835     /**
1836      * @return iron in {@link Mass} unit.
1837      */
1838     @Nullable
getIron()1839     public Mass getIron() {
1840         return mIron;
1841     }
1842 
1843     /**
1844      * @return vitaminA in {@link Mass} unit.
1845      */
1846     @Nullable
getVitaminA()1847     public Mass getVitaminA() {
1848         return mVitaminA;
1849     }
1850 
1851     /**
1852      * @return folicAcid in {@link Mass} unit.
1853      */
1854     @Nullable
getFolicAcid()1855     public Mass getFolicAcid() {
1856         return mFolicAcid;
1857     }
1858 
1859     /**
1860      * @return sugar in {@link Mass} unit.
1861      */
1862     @Nullable
getSugar()1863     public Mass getSugar() {
1864         return mSugar;
1865     }
1866 
1867     /**
1868      * Indicates whether some other object is "equal to" this one.
1869      *
1870      * @param o the reference object with which to compare.
1871      * @return {@code true} if this object is the same as the obj
1872      */
1873     @SuppressWarnings("NullAway") // TODO(b/317029272): fix this suppression
1874     @Override
equals(Object o)1875     public boolean equals(Object o) {
1876         if (this == o) return true;
1877         if (!super.equals(o)) return false;
1878         NutritionRecord that = (NutritionRecord) o;
1879         return getMealType() == that.getMealType()
1880                 && Objects.equals(getUnsaturatedFat(), that.getUnsaturatedFat())
1881                 && Objects.equals(getPotassium(), that.getPotassium())
1882                 && Objects.equals(getThiamin(), that.getThiamin())
1883                 && Objects.equals(getTransFat(), that.getTransFat())
1884                 && Objects.equals(getManganese(), that.getManganese())
1885                 && Objects.equals(getEnergyFromFat(), that.getEnergyFromFat())
1886                 && Objects.equals(getCaffeine(), that.getCaffeine())
1887                 && Objects.equals(getDietaryFiber(), that.getDietaryFiber())
1888                 && Objects.equals(getSelenium(), that.getSelenium())
1889                 && Objects.equals(getVitaminB6(), that.getVitaminB6())
1890                 && Objects.equals(getProtein(), that.getProtein())
1891                 && Objects.equals(getChloride(), that.getChloride())
1892                 && Objects.equals(getCholesterol(), that.getCholesterol())
1893                 && Objects.equals(getCopper(), that.getCopper())
1894                 && Objects.equals(getIodine(), that.getIodine())
1895                 && Objects.equals(getVitaminB12(), that.getVitaminB12())
1896                 && Objects.equals(getZinc(), that.getZinc())
1897                 && Objects.equals(getRiboflavin(), that.getRiboflavin())
1898                 && Objects.equals(getEnergy(), that.getEnergy())
1899                 && Objects.equals(getMolybdenum(), that.getMolybdenum())
1900                 && Objects.equals(getPhosphorus(), that.getPhosphorus())
1901                 && Objects.equals(getChromium(), that.getChromium())
1902                 && Objects.equals(getTotalFat(), that.getTotalFat())
1903                 && Objects.equals(getCalcium(), that.getCalcium())
1904                 && Objects.equals(getVitaminC(), that.getVitaminC())
1905                 && Objects.equals(getVitaminE(), that.getVitaminE())
1906                 && Objects.equals(getBiotin(), that.getBiotin())
1907                 && Objects.equals(getVitaminD(), that.getVitaminD())
1908                 && Objects.equals(getNiacin(), that.getNiacin())
1909                 && Objects.equals(getMagnesium(), that.getMagnesium())
1910                 && Objects.equals(getTotalCarbohydrate(), that.getTotalCarbohydrate())
1911                 && Objects.equals(getVitaminK(), that.getVitaminK())
1912                 && Objects.equals(getPolyunsaturatedFat(), that.getPolyunsaturatedFat())
1913                 && Objects.equals(getSaturatedFat(), that.getSaturatedFat())
1914                 && Objects.equals(getSodium(), that.getSodium())
1915                 && Objects.equals(getFolate(), that.getFolate())
1916                 && Objects.equals(getMonounsaturatedFat(), that.getMonounsaturatedFat())
1917                 && Objects.equals(getPantothenicAcid(), that.getPantothenicAcid())
1918                 && Objects.equals(getMealName(), that.getMealName())
1919                 && Objects.equals(getIron(), that.getIron())
1920                 && Objects.equals(getVitaminA(), that.getVitaminA())
1921                 && Objects.equals(getFolicAcid(), that.getFolicAcid())
1922                 && Objects.equals(getSugar(), that.getSugar());
1923     }
1924 
1925     /**
1926      * @return a hash code value for this object.
1927      */
1928     @Override
hashCode()1929     public int hashCode() {
1930         return Objects.hash(
1931                 super.hashCode(),
1932                 getMealType(),
1933                 getUnsaturatedFat(),
1934                 getPotassium(),
1935                 getThiamin(),
1936                 getTransFat(),
1937                 getManganese(),
1938                 getEnergyFromFat(),
1939                 getCaffeine(),
1940                 getDietaryFiber(),
1941                 getSelenium(),
1942                 getVitaminB6(),
1943                 getProtein(),
1944                 getChloride(),
1945                 getCholesterol(),
1946                 getCopper(),
1947                 getIodine(),
1948                 getVitaminB12(),
1949                 getZinc(),
1950                 getRiboflavin(),
1951                 getEnergy(),
1952                 getMolybdenum(),
1953                 getPhosphorus(),
1954                 getChromium(),
1955                 getTotalFat(),
1956                 getCalcium(),
1957                 getVitaminC(),
1958                 getVitaminE(),
1959                 getBiotin(),
1960                 getVitaminD(),
1961                 getNiacin(),
1962                 getMagnesium(),
1963                 getTotalCarbohydrate(),
1964                 getVitaminK(),
1965                 getPolyunsaturatedFat(),
1966                 getSaturatedFat(),
1967                 getSodium(),
1968                 getFolate(),
1969                 getMonounsaturatedFat(),
1970                 getPantothenicAcid(),
1971                 getMealName(),
1972                 getIron(),
1973                 getVitaminA(),
1974                 getFolicAcid(),
1975                 getSugar());
1976     }
1977 
1978     /** @hide */
1979     @Override
toRecordInternal()1980     public NutritionRecordInternal toRecordInternal() {
1981         NutritionRecordInternal recordInternal =
1982                 (NutritionRecordInternal)
1983                         new NutritionRecordInternal()
1984                                 .setUuid(getMetadata().getId())
1985                                 .setPackageName(getMetadata().getDataOrigin().getPackageName())
1986                                 .setLastModifiedTime(
1987                                         getMetadata().getLastModifiedTime().toEpochMilli())
1988                                 .setClientRecordId(getMetadata().getClientRecordId())
1989                                 .setClientRecordVersion(getMetadata().getClientRecordVersion())
1990                                 .setManufacturer(getMetadata().getDevice().getManufacturer())
1991                                 .setModel(getMetadata().getDevice().getModel())
1992                                 .setDeviceType(getMetadata().getDevice().getType())
1993                                 .setRecordingMethod(getMetadata().getRecordingMethod());
1994 
1995         recordInternal.setStartTime(getStartTime().toEpochMilli());
1996         recordInternal.setEndTime(getEndTime().toEpochMilli());
1997         recordInternal.setStartZoneOffset(getStartZoneOffset().getTotalSeconds());
1998         recordInternal.setEndZoneOffset(getEndZoneOffset().getTotalSeconds());
1999 
2000         if (!Objects.isNull(getUnsaturatedFat())) {
2001             recordInternal.setUnsaturatedFat(getUnsaturatedFat().getInGrams());
2002         }
2003         if (!Objects.isNull(getPotassium())) {
2004             recordInternal.setPotassium(getPotassium().getInGrams());
2005         }
2006         if (!Objects.isNull(getThiamin())) {
2007             recordInternal.setThiamin(getThiamin().getInGrams());
2008         }
2009         recordInternal.setMealType(getMealType());
2010         if (!Objects.isNull(getTransFat())) {
2011             recordInternal.setTransFat(getTransFat().getInGrams());
2012         }
2013         if (!Objects.isNull(getManganese())) {
2014             recordInternal.setManganese(getManganese().getInGrams());
2015         }
2016         if (!Objects.isNull(getEnergyFromFat())) {
2017             recordInternal.setEnergyFromFat(getEnergyFromFat().getInCalories());
2018         }
2019         if (!Objects.isNull(getCaffeine())) {
2020             recordInternal.setCaffeine(getCaffeine().getInGrams());
2021         }
2022         if (!Objects.isNull(getDietaryFiber())) {
2023             recordInternal.setDietaryFiber(getDietaryFiber().getInGrams());
2024         }
2025         if (!Objects.isNull(getSelenium())) {
2026             recordInternal.setSelenium(getSelenium().getInGrams());
2027         }
2028         if (!Objects.isNull(getVitaminB6())) {
2029             recordInternal.setVitaminB6(getVitaminB6().getInGrams());
2030         }
2031         if (!Objects.isNull(getProtein())) {
2032             recordInternal.setProtein(getProtein().getInGrams());
2033         }
2034         if (!Objects.isNull(getChloride())) {
2035             recordInternal.setChloride(getChloride().getInGrams());
2036         }
2037         if (!Objects.isNull(getCholesterol())) {
2038             recordInternal.setCholesterol(getCholesterol().getInGrams());
2039         }
2040         if (!Objects.isNull(getCopper())) {
2041             recordInternal.setCopper(getCopper().getInGrams());
2042         }
2043         if (!Objects.isNull(getIodine())) {
2044             recordInternal.setIodine(getIodine().getInGrams());
2045         }
2046         if (!Objects.isNull(getVitaminB12())) {
2047             recordInternal.setVitaminB12(getVitaminB12().getInGrams());
2048         }
2049         if (!Objects.isNull(getZinc())) {
2050             recordInternal.setZinc(getZinc().getInGrams());
2051         }
2052         if (!Objects.isNull(getRiboflavin())) {
2053             recordInternal.setRiboflavin(getRiboflavin().getInGrams());
2054         }
2055         if (!Objects.isNull(getEnergy())) {
2056             recordInternal.setEnergy(getEnergy().getInCalories());
2057         }
2058         if (!Objects.isNull(getMolybdenum())) {
2059             recordInternal.setMolybdenum(getMolybdenum().getInGrams());
2060         }
2061         if (!Objects.isNull(getPhosphorus())) {
2062             recordInternal.setPhosphorus(getPhosphorus().getInGrams());
2063         }
2064         if (!Objects.isNull(getChromium())) {
2065             recordInternal.setChromium(getChromium().getInGrams());
2066         }
2067         if (!Objects.isNull(getTotalFat())) {
2068             recordInternal.setTotalFat(getTotalFat().getInGrams());
2069         }
2070         if (!Objects.isNull(getCalcium())) {
2071             recordInternal.setCalcium(getCalcium().getInGrams());
2072         }
2073         if (!Objects.isNull(getVitaminC())) {
2074             recordInternal.setVitaminC(getVitaminC().getInGrams());
2075         }
2076         if (!Objects.isNull(getVitaminE())) {
2077             recordInternal.setVitaminE(getVitaminE().getInGrams());
2078         }
2079         if (!Objects.isNull(getBiotin())) {
2080             recordInternal.setBiotin(getBiotin().getInGrams());
2081         }
2082         if (!Objects.isNull(getVitaminD())) {
2083             recordInternal.setVitaminD(getVitaminD().getInGrams());
2084         }
2085         if (!Objects.isNull(getNiacin())) {
2086             recordInternal.setNiacin(getNiacin().getInGrams());
2087         }
2088         if (!Objects.isNull(getMagnesium())) {
2089             recordInternal.setMagnesium(getMagnesium().getInGrams());
2090         }
2091         if (!Objects.isNull(getTotalCarbohydrate())) {
2092             recordInternal.setTotalCarbohydrate(getTotalCarbohydrate().getInGrams());
2093         }
2094         if (!Objects.isNull(getVitaminK())) {
2095             recordInternal.setVitaminK(getVitaminK().getInGrams());
2096         }
2097         if (!Objects.isNull(getPolyunsaturatedFat())) {
2098             recordInternal.setPolyunsaturatedFat(getPolyunsaturatedFat().getInGrams());
2099         }
2100         if (!Objects.isNull(getSaturatedFat())) {
2101             recordInternal.setSaturatedFat(getSaturatedFat().getInGrams());
2102         }
2103         if (!Objects.isNull(getSodium())) {
2104             recordInternal.setSodium(getSodium().getInGrams());
2105         }
2106         if (!Objects.isNull(getFolate())) {
2107             recordInternal.setFolate(getFolate().getInGrams());
2108         }
2109         if (!Objects.isNull(getMonounsaturatedFat())) {
2110             recordInternal.setMonounsaturatedFat(getMonounsaturatedFat().getInGrams());
2111         }
2112         if (!Objects.isNull(getPantothenicAcid())) {
2113             recordInternal.setPantothenicAcid(getPantothenicAcid().getInGrams());
2114         }
2115         if (!Objects.isNull(getMealName())) {
2116             recordInternal.setMealName(getMealName());
2117         }
2118         if (!Objects.isNull(getIron())) {
2119             recordInternal.setIron(getIron().getInGrams());
2120         }
2121         if (!Objects.isNull(getVitaminA())) {
2122             recordInternal.setVitaminA(getVitaminA().getInGrams());
2123         }
2124         if (!Objects.isNull(getFolicAcid())) {
2125             recordInternal.setFolicAcid(getFolicAcid().getInGrams());
2126         }
2127         if (!Objects.isNull(getSugar())) {
2128             recordInternal.setSugar(getSugar().getInGrams());
2129         }
2130 
2131         return recordInternal;
2132     }
2133 }
2134