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.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 import com.google.common.hash.HashCode; 25 26 /** 27 * A string hash and its relative order in the string hash list for a given report and day. 28 * 29 * <p>Values are tagged with @ColumnInfo so a {@link StringListEntry} can be automatically read from 30 * tables. 31 */ 32 @AutoValue 33 public abstract class StringListEntry { 34 /** 35 * The index of the string hash in the hash list. 36 * 37 * <p>This value is shared with the persisted aggregate values. 38 */ 39 @CopyAnnotations 40 @ColumnInfo(name = "list_index") 41 @NonNull listIndex()42 public abstract int listIndex(); 43 44 /** The string hash. */ 45 @CopyAnnotations 46 @ColumnInfo(name = "string_hash") 47 @NonNull stringHash()48 public abstract HashCode stringHash(); 49 50 /** 51 * Creates a {@link StringListEntry}. 52 * 53 * <p>Used by Room to instantiate objects. 54 */ 55 @NonNull create(int listIndex, HashCode stringHash)56 public static StringListEntry create(int listIndex, HashCode stringHash) { 57 return new AutoValue_StringListEntry(listIndex, stringHash); 58 } 59 } 60