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.internal.datatypes;
17 
18 import android.annotation.NonNull;
19 import android.health.connect.datatypes.FloorsClimbedRecord;
20 import android.health.connect.datatypes.Identifier;
21 import android.health.connect.datatypes.RecordTypeIdentifier;
22 import android.os.Parcel;
23 
24 /**
25  * @see FloorsClimbedRecord
26  * @hide
27  */
28 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_FLOORS_CLIMBED)
29 public final class FloorsClimbedRecordInternal extends IntervalRecordInternal<FloorsClimbedRecord> {
30     private double mFloors;
31 
getFloors()32     public double getFloors() {
33         return mFloors;
34     }
35 
36     /** returns this object with the specified floors */
37     @NonNull
setFloors(double floors)38     public FloorsClimbedRecordInternal setFloors(double floors) {
39         this.mFloors = floors;
40         return this;
41     }
42 
43     @NonNull
44     @Override
toExternalRecord()45     public FloorsClimbedRecord toExternalRecord() {
46         return new FloorsClimbedRecord.Builder(
47                         buildMetaData(), getStartTime(), getEndTime(), getFloors())
48                 .setStartZoneOffset(getStartZoneOffset())
49                 .setEndZoneOffset(getEndZoneOffset())
50                 .buildWithoutValidation();
51     }
52 
53     @Override
populateIntervalRecordFrom(@onNull Parcel parcel)54     void populateIntervalRecordFrom(@NonNull Parcel parcel) {
55         mFloors = parcel.readDouble();
56     }
57 
58     @Override
populateIntervalRecordTo(@onNull Parcel parcel)59     void populateIntervalRecordTo(@NonNull Parcel parcel) {
60         parcel.writeDouble(mFloors);
61     }
62 }
63