• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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.measurement.aggregation;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.net.Uri;
22 
23 import com.android.adservices.service.measurement.util.Validation;
24 
25 import java.util.Objects;
26 
27 /** POJO for AggregateDebugReportData. */
28 public class AggregateDebugReportRecord {
29 
30     private final long mReportGenerationTime;
31     private final Uri mTopLevelRegistrant;
32     private final Uri mRegistrantApp;
33     private final Uri mRegistrationOrigin;
34     @Nullable private final String mSourceId;
35     @Nullable private final String mTriggerId;
36     private final int mContributions;
37 
AggregateDebugReportRecord(@onNull AggregateDebugReportRecord.Builder builder)38     private AggregateDebugReportRecord(@NonNull AggregateDebugReportRecord.Builder builder) {
39         mReportGenerationTime = builder.mReportGenerationTime;
40         mTopLevelRegistrant = builder.mTopLevelRegistrant;
41         mRegistrantApp = builder.mRegistrantApp;
42         mRegistrationOrigin = builder.mRegistrationOrigin;
43         mSourceId = builder.mSourceId;
44         mTriggerId = builder.mTriggerId;
45         mContributions = builder.mContributions;
46     }
47 
48     @Override
equals(Object obj)49     public boolean equals(Object obj) {
50         if (!(obj instanceof AggregateDebugReportRecord aggregateDebugReportRecord)) {
51             return false;
52         }
53         return mReportGenerationTime == aggregateDebugReportRecord.mReportGenerationTime
54                 && Objects.equals(
55                         mTopLevelRegistrant, aggregateDebugReportRecord.mTopLevelRegistrant)
56                 && Objects.equals(mRegistrantApp, aggregateDebugReportRecord.mRegistrantApp)
57                 && Objects.equals(
58                         mRegistrationOrigin, aggregateDebugReportRecord.mRegistrationOrigin)
59                 && Objects.equals(mSourceId, aggregateDebugReportRecord.mSourceId)
60                 && Objects.equals(mTriggerId, aggregateDebugReportRecord.mTriggerId)
61                 && mContributions == aggregateDebugReportRecord.mContributions;
62     }
63 
64     @Override
hashCode()65     public int hashCode() {
66         return Objects.hash(
67                 mReportGenerationTime,
68                 mTopLevelRegistrant,
69                 mRegistrantApp,
70                 mRegistrationOrigin,
71                 mSourceId,
72                 mTriggerId,
73                 mContributions);
74     }
75 
76     /** Returns the value of report generation time. */
getReportGenerationTime()77     public long getReportGenerationTime() {
78         return mReportGenerationTime;
79     }
80 
81     /** Returns the value of top level registrant. */
getTopLevelRegistrant()82     public Uri getTopLevelRegistrant() {
83         return mTopLevelRegistrant;
84     }
85 
86     /** Returns the value of registrant app. */
getRegistrantApp()87     public Uri getRegistrantApp() {
88         return mRegistrantApp;
89     }
90 
91     /** Returns the value of registrant origin. */
getRegistrationOrigin()92     public Uri getRegistrationOrigin() {
93         return mRegistrationOrigin;
94     }
95 
96     /** Returns the value of source id. */
getSourceId()97     public String getSourceId() {
98         return mSourceId;
99     }
100 
101     /** Returns the value of trigger id. */
getTriggerId()102     public String getTriggerId() {
103         return mTriggerId;
104     }
105 
106     /** Returns the value of contributions. */
getContributions()107     public int getContributions() {
108         return mContributions;
109     }
110 
111     /** Builder for {@link AggregateDebugReportRecord}. */
112     public static final class Builder {
113         private long mReportGenerationTime;
114         private Uri mTopLevelRegistrant;
115         private Uri mRegistrantApp;
116         private Uri mRegistrationOrigin;
117         @Nullable private String mSourceId;
118         @Nullable private String mTriggerId;
119         private final int mContributions;
120 
Builder( long reportGenerationTime, Uri topLevelRegistrant, Uri registrantApp, Uri registrationOrigin, int contributions)121         public Builder(
122                 long reportGenerationTime,
123                 Uri topLevelRegistrant,
124                 Uri registrantApp,
125                 Uri registrationOrigin,
126                 int contributions) {
127             mReportGenerationTime = reportGenerationTime;
128             mTopLevelRegistrant = topLevelRegistrant;
129             mRegistrantApp = registrantApp;
130             mRegistrationOrigin = registrationOrigin;
131             mContributions = contributions;
132         }
133 
134         /** See {@link AggregateDebugReportRecord#getSourceId()}. */
135         @NonNull
setSourceId(@ullable String sourceId)136         public Builder setSourceId(@Nullable String sourceId) {
137             mSourceId = sourceId;
138             return this;
139         }
140 
141         /** See {@link AggregateDebugReportRecord#getTriggerId()}. */
142         @NonNull
setTriggerId(@ullable String triggerId)143         public Builder setTriggerId(@Nullable String triggerId) {
144             mTriggerId = triggerId;
145             return this;
146         }
147 
148         /** Build the {@link AggregateDebugReportRecord} */
build()149         public AggregateDebugReportRecord build() {
150             Validation.validateNonNull(mTopLevelRegistrant, mRegistrantApp, mRegistrationOrigin);
151             return new AggregateDebugReportRecord(this);
152         }
153     }
154 }
155