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 17 package android.health.connect.internal.datatypes; 18 19 import android.annotation.NonNull; 20 import android.health.connect.datatypes.BodyWaterMassRecord; 21 import android.health.connect.datatypes.Identifier; 22 import android.health.connect.datatypes.RecordTypeIdentifier; 23 import android.health.connect.datatypes.units.Mass; 24 import android.os.Parcel; 25 26 /** @hide */ 27 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_BODY_WATER_MASS) 28 public final class BodyWaterMassRecordInternal extends InstantRecordInternal<BodyWaterMassRecord> { 29 private double mBodyWaterMass = 0.0; 30 31 @Override populateInstantRecordFrom(@onNull Parcel parcel)32 void populateInstantRecordFrom(@NonNull Parcel parcel) { 33 mBodyWaterMass = parcel.readDouble(); 34 } 35 36 @Override populateInstantRecordTo(@onNull Parcel parcel)37 void populateInstantRecordTo(@NonNull Parcel parcel) { 38 parcel.writeDouble(mBodyWaterMass); 39 } 40 getBodyWaterMass()41 public double getBodyWaterMass() { 42 return mBodyWaterMass; 43 } 44 setBodyWaterMass(double bodyWaterMass)45 public void setBodyWaterMass(double bodyWaterMass) { 46 mBodyWaterMass = bodyWaterMass; 47 } 48 49 @NonNull 50 @Override toExternalRecord()51 public BodyWaterMassRecord toExternalRecord() { 52 return new BodyWaterMassRecord.Builder( 53 buildMetaData(), getTime(), Mass.fromGrams(getBodyWaterMass())) 54 .setZoneOffset(getZoneOffset()) 55 .buildWithoutValidation(); 56 } 57 } 58