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.cobalt.data; 18 19 import androidx.annotation.NonNull; 20 import androidx.room.ColumnInfo; 21 22 import com.google.auto.value.AutoValue; 23 import com.google.auto.value.AutoValue.CopyAnnotations; 24 25 /** 26 * All the identifiers needed to uniquely identify a report. 27 * 28 * <p>Values are tagged with @ColumnInfo so a {@link ReportKey} can be automatically read from 29 * tables. 30 */ 31 @AutoValue 32 public abstract class ReportKey { 33 /** The customer id. */ 34 @CopyAnnotations 35 @ColumnInfo(name = "customer_id") 36 @NonNull customerId()37 public abstract long customerId(); 38 39 /** The project id. */ 40 @CopyAnnotations 41 @ColumnInfo(name = "project_id") 42 @NonNull projectId()43 public abstract long projectId(); 44 45 /** The metric id. */ 46 @CopyAnnotations 47 @ColumnInfo(name = "metric_id") 48 @NonNull metricId()49 public abstract long metricId(); 50 51 /** The report id. */ 52 @CopyAnnotations 53 @ColumnInfo(name = "report_id") 54 @NonNull reportId()55 public abstract long reportId(); 56 57 /** 58 * Creates a {@link ReportKey}. 59 * 60 * <p>Used by Room to instantiate objects. 61 */ 62 @NonNull create(long customerId, long projectId, long metricId, long reportId)63 public static ReportKey create(long customerId, long projectId, long metricId, long reportId) { 64 return new AutoValue_ReportKey(customerId, projectId, metricId, reportId); 65 } 66 } 67