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.ratelimiter;
18 
19 import android.annotation.NonNull;
20 
21 import java.time.Instant;
22 import java.util.Objects;
23 
24 /**
25  * Object to store the last update time and remaining quota for quota buckets as used in {@link
26  * RateLimiter}.
27  *
28  * @hide
29  */
30 public final class Quota {
31     private Instant mLastUpdatedTime;
32     private float mRemainingQuota;
33 
Quota(@onNull Instant lastUpdatedTime, float remainingQuota)34     public Quota(@NonNull Instant lastUpdatedTime, float remainingQuota) {
35         Objects.requireNonNull(lastUpdatedTime);
36 
37         mLastUpdatedTime = lastUpdatedTime;
38         mRemainingQuota = remainingQuota;
39     }
40 
41     @NonNull
getLastUpdatedTime()42     public Instant getLastUpdatedTime() {
43         return mLastUpdatedTime;
44     }
45 
getRemainingQuota()46     public float getRemainingQuota() {
47         return mRemainingQuota;
48     }
49 
setLastUpdatedTime(Instant lastUpdatedTime)50     public void setLastUpdatedTime(Instant lastUpdatedTime) {
51         mLastUpdatedTime = lastUpdatedTime;
52     }
53 
setRemainingQuota(Float remainingQuota)54     public void setRemainingQuota(Float remainingQuota) {
55         mRemainingQuota = remainingQuota;
56     }
57 }
58