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 com.android.adservices.data.adselection.datahandlers;
18 
19 import android.adservices.common.AdTechIdentifier;
20 import android.annotation.NonNull;
21 
22 
23 import com.google.auto.value.AutoValue;
24 
25 import java.time.Instant;
26 
27 /** Data class representing an ad selection run instantiation. */
28 @AutoValue
29 public abstract class AdSelectionInitialization {
30 
31     /** AdTech initiating this ad selection run. */
32     @NonNull
getSeller()33     public abstract AdTechIdentifier getSeller();
34 
35     /** Caller package name initiating this ad selection run. */
36     @NonNull
getCallerPackageName()37     public abstract String getCallerPackageName();
38 
39     /** The creation time for this ad selection run. */
40     @NonNull
getCreationInstant()41     public abstract Instant getCreationInstant();
42 
43     /**
44      * @return generic builder
45      */
46     @NonNull
builder()47     public static Builder builder() {
48         return new AutoValue_AdSelectionInitialization.Builder();
49     }
50 
51     /**
52      * Creates a {@link AdSelectionInitialization} object using the builder.
53      *
54      * <p>Required for Room SQLite integration.
55      */
56     @NonNull
create( @onNull AdTechIdentifier seller, @NonNull String callerPackageName, @NonNull Instant creationInstant)57     public static AdSelectionInitialization create(
58             @NonNull AdTechIdentifier seller,
59             @NonNull String callerPackageName,
60             @NonNull Instant creationInstant) {
61         return builder()
62                 .setSeller(seller)
63                 .setCallerPackageName(callerPackageName)
64                 .setCreationInstant(creationInstant)
65                 .build();
66     }
67 
68     /** Builder for AdSelectionInitialization. */
69     @AutoValue.Builder
70     public abstract static class Builder {
71         /** Sets the AdTech initiating this ad selection run. */
setSeller(@onNull AdTechIdentifier seller)72         public abstract Builder setSeller(@NonNull AdTechIdentifier seller);
73 
74         /** Sets the caller package name initiating this ad selection run. */
setCallerPackageName(@onNull String callerPackageName)75         public abstract Builder setCallerPackageName(@NonNull String callerPackageName);
76 
77         /** Sets the caller package name initiating this ad selection run. */
setCreationInstant(@onNull Instant creationInstant)78         public abstract Builder setCreationInstant(@NonNull Instant creationInstant);
79 
80         /** Builds a {@link AdSelectionInitialization} object. */
81         @NonNull
build()82         public abstract AdSelectionInitialization build();
83     }
84 }
85