• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2022 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 com.android.adservices.service.stats;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 
22 import java.util.Objects;
23 
24 /** Class for measurement registration response Stats. */
25 public class MeasurementRegistrationResponseStats {
26     private final int mCode;
27     private final int mRegistrationType;
28     private final long mResponseSize;
29     private final String mAdTechDomain;
30     private final int mInteractionType;
31     private final int mSurfaceType;
32     private final int mRegistrationStatus;
33     private final int mFailureType;
34     private final long mRegistrationDelay;
35 
MeasurementRegistrationResponseStats(Builder builder)36     private MeasurementRegistrationResponseStats(Builder builder) {
37         mCode = builder.mCode;
38         mRegistrationType = builder.mRegistrationType;
39         mResponseSize = builder.mResponseSize;
40         mAdTechDomain = builder.mAdTechDomain;
41         mInteractionType = builder.mInteractionType;
42         mSurfaceType = builder.mSurfaceType;
43         mRegistrationStatus = builder.mRegistrationStatus;
44         mFailureType = builder.mFailureType;
45         mRegistrationDelay = builder.mRegistrationDelay;
46     }
47 
48     @Override
equals(Object o)49     public boolean equals(Object o) {
50         if (this == o) return true;
51         if (!(o instanceof MeasurementRegistrationResponseStats)) return false;
52         MeasurementRegistrationResponseStats that = (MeasurementRegistrationResponseStats) o;
53         return mCode == that.mCode
54                 && mRegistrationType == that.mRegistrationType
55                 && mResponseSize == that.mResponseSize
56                 && Objects.equals(mAdTechDomain, that.mAdTechDomain)
57                 && mInteractionType == that.mInteractionType
58                 && mSurfaceType == that.mSurfaceType
59                 && mRegistrationStatus == that.mRegistrationStatus
60                 && mFailureType == that.mFailureType
61                 && mRegistrationDelay == that.mRegistrationDelay;
62     }
63 
64     @Override
hashCode()65     public int hashCode() {
66         return Objects.hash(
67                 mCode,
68                 mRegistrationType,
69                 mResponseSize,
70                 mAdTechDomain,
71                 mInteractionType,
72                 mSurfaceType,
73                 mRegistrationStatus,
74                 mFailureType,
75                 mRegistrationDelay);
76     }
77 
78     @Override
toString()79     public String toString() {
80         return "MeasurementRegistrationResponseStats{"
81                 + "mCode="
82                 + mCode
83                 + ", mRegistrationType="
84                 + mRegistrationType
85                 + ", mResponseSize="
86                 + mResponseSize
87                 + ", mAdTechDomain='"
88                 + mAdTechDomain
89                 + ", mInteractionType="
90                 + mInteractionType
91                 + ", mSurfaceType="
92                 + mSurfaceType
93                 + ", mRegistrationStatus="
94                 + mRegistrationStatus
95                 + ", mFailureType="
96                 + mFailureType
97                 + ", mRegistrationDelay="
98                 + mRegistrationDelay
99                 + '}';
100     }
101 
getCode()102     public int getCode() {
103         return mCode;
104     }
105 
getRegistrationType()106     public int getRegistrationType() {
107         return mRegistrationType;
108     }
109 
getResponseSize()110     public long getResponseSize() {
111         return mResponseSize;
112     }
113 
114     @Nullable
getAdTechDomain()115     public String getAdTechDomain() {
116         return mAdTechDomain;
117     }
118 
getInteractionType()119     public int getInteractionType() {
120         return mInteractionType;
121     }
122 
getSurfaceType()123     public int getSurfaceType() {
124         return mSurfaceType;
125     }
126 
getRegistrationStatus()127     public int getRegistrationStatus() {
128         return mRegistrationStatus;
129     }
130 
getFailureType()131     public int getFailureType() {
132         return mFailureType;
133     }
134 
getRegistrationDelay()135     public long getRegistrationDelay() {
136         return mRegistrationDelay;
137     }
138 
139     /** Builder for {@link MeasurementRegistrationResponseStats}. */
140     public static final class Builder {
141         private final int mCode;
142         private final int mRegistrationType;
143         private final long mResponseSize;
144         private String mAdTechDomain;
145         private final int mInteractionType;
146         private final int mSurfaceType;
147         private final int mRegistrationStatus;
148         private final int mFailureType;
149         private final long mRegistrationDelay;
150 
Builder( int code, int registrationType, long responseSize, int interactionType, int surfaceType, int registrationStatus, int failureType, long registrationDelay)151         public Builder(
152                 int code,
153                 int registrationType,
154                 long responseSize,
155                 int interactionType,
156                 int surfaceType,
157                 int registrationStatus,
158                 int failureType,
159                 long registrationDelay) {
160             mCode = code;
161             mRegistrationType = registrationType;
162             mResponseSize = responseSize;
163             mInteractionType = interactionType;
164             mSurfaceType = surfaceType;
165             mRegistrationStatus = registrationStatus;
166             mFailureType = failureType;
167             mRegistrationDelay = registrationDelay;
168         }
169 
170         /** See {@link MeasurementRegistrationResponseStats#getAdTechDomain()} . */
171         @NonNull
setAdTechDomain( @ullable String adTechDomain)172         public MeasurementRegistrationResponseStats.Builder setAdTechDomain(
173                 @Nullable String adTechDomain) {
174             mAdTechDomain = adTechDomain;
175             return this;
176         }
177 
178         /** Build the {@link MeasurementRegistrationResponseStats}. */
179         @NonNull
build()180         public MeasurementRegistrationResponseStats build() {
181             return new MeasurementRegistrationResponseStats(this);
182         }
183     }
184 }
185