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.signals; 18 19 import android.adservices.common.AdTechIdentifier; 20 21 import androidx.annotation.NonNull; 22 import androidx.room.ColumnInfo; 23 import androidx.room.Entity; 24 import androidx.room.PrimaryKey; 25 26 import com.google.auto.value.AutoValue; 27 28 import java.time.Instant; 29 30 /** Represents an entry for signals update metadata. */ 31 @AutoValue 32 @AutoValue.CopyAnnotations 33 @Entity(tableName = DBSignalsUpdateMetadata.TABLE_NAME, inheritSuperIndices = true) 34 public abstract class DBSignalsUpdateMetadata { 35 36 public static final String TABLE_NAME = "signals_update_metadata"; 37 38 /** The ad-tech buyer */ 39 @AutoValue.CopyAnnotations 40 @ColumnInfo(name = "buyer") 41 @PrimaryKey 42 @NonNull getBuyer()43 public abstract AdTechIdentifier getBuyer(); 44 45 /** The last time update happened to a buyer's signals */ 46 @AutoValue.CopyAnnotations 47 @ColumnInfo(name = "last_signals_updated_time") getLastSignalsUpdatedTime()48 public abstract Instant getLastSignalsUpdatedTime(); 49 50 /** 51 * @return an instance of {@link DBSignalsUpdateMetadata} 52 */ create( @onNull AdTechIdentifier buyer, @NonNull Instant lastSignalsUpdatedTime)53 public static DBSignalsUpdateMetadata create( 54 @NonNull AdTechIdentifier buyer, @NonNull Instant lastSignalsUpdatedTime) { 55 return builder().setBuyer(buyer).setLastSignalsUpdatedTime(lastSignalsUpdatedTime).build(); 56 } 57 58 /** 59 * @return a builder for creating a {@link DBSignalsUpdateMetadata} 60 */ builder()61 public static DBSignalsUpdateMetadata.Builder builder() { 62 return new AutoValue_DBSignalsUpdateMetadata.Builder(); 63 } 64 65 /** Provides a builder to create an instance of {@link DBSignalsUpdateMetadata} */ 66 @AutoValue.Builder 67 public abstract static class Builder { 68 69 /** For more details see {@link #getBuyer()} */ setBuyer(@onNull AdTechIdentifier value)70 public abstract DBSignalsUpdateMetadata.Builder setBuyer(@NonNull AdTechIdentifier value); 71 72 /** For more details see {@link #getLastSignalsUpdatedTime()} ()} */ setLastSignalsUpdatedTime( @onNull Instant value)73 public abstract DBSignalsUpdateMetadata.Builder setLastSignalsUpdatedTime( 74 @NonNull Instant value); 75 76 /** 77 * @return an instance of {@link DBSignalsUpdateMetadata} 78 */ build()79 public abstract DBSignalsUpdateMetadata build(); 80 } 81 } 82