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.CervicalMucusRecord; 20 import android.health.connect.datatypes.CervicalMucusRecord.CervicalMucusAppearance; 21 import android.health.connect.datatypes.CervicalMucusRecord.CervicalMucusSensation; 22 import android.health.connect.datatypes.Identifier; 23 import android.health.connect.datatypes.RecordTypeIdentifier; 24 import android.os.Parcel; 25 26 /** 27 * @see CervicalMucusRecord 28 * @hide 29 */ 30 @Identifier(recordIdentifier = RecordTypeIdentifier.RECORD_TYPE_CERVICAL_MUCUS) 31 public final class CervicalMucusRecordInternal extends InstantRecordInternal<CervicalMucusRecord> { 32 private int mSensation; 33 private int mAppearance; 34 35 @CervicalMucusSensation.CervicalMucusSensations getSensation()36 public int getSensation() { 37 return mSensation; 38 } 39 40 /** returns this object with the specified sensation */ 41 @NonNull setSensation(int sensation)42 public CervicalMucusRecordInternal setSensation(int sensation) { 43 this.mSensation = sensation; 44 return this; 45 } 46 47 @CervicalMucusAppearance.CervicalMucusAppearances getAppearance()48 public int getAppearance() { 49 return mAppearance; 50 } 51 52 /** returns this object with the specified appearance */ 53 @NonNull setAppearance(int appearance)54 public CervicalMucusRecordInternal setAppearance(int appearance) { 55 this.mAppearance = appearance; 56 return this; 57 } 58 59 @NonNull 60 @Override toExternalRecord()61 public CervicalMucusRecord toExternalRecord() { 62 return new CervicalMucusRecord.Builder( 63 buildMetaData(), getTime(), getSensation(), getAppearance()) 64 .setZoneOffset(getZoneOffset()) 65 .buildWithoutValidation(); 66 } 67 68 @Override populateInstantRecordFrom(@onNull Parcel parcel)69 void populateInstantRecordFrom(@NonNull Parcel parcel) { 70 mSensation = parcel.readInt(); 71 mAppearance = parcel.readInt(); 72 } 73 74 @Override populateInstantRecordTo(@onNull Parcel parcel)75 void populateInstantRecordTo(@NonNull Parcel parcel) { 76 parcel.writeInt(mSensation); 77 parcel.writeInt(mAppearance); 78 } 79 } 80