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 import com.google.cobalt.AggregateValue; 25 26 /** 27 * Encapsulates the values required for aggregation at log time. 28 * 29 * <p>Values are tagged with @ColumnInfo so a {@link SystemProfileAndAggregateValue} can be 30 * automatically read from tables. 31 */ 32 @AutoValue 33 @CopyAnnotations 34 abstract class SystemProfileAndAggregateValue { 35 /** The system profile hash. */ 36 @CopyAnnotations 37 @ColumnInfo(name = "system_profile_hash") 38 @NonNull systemProfileHash()39 abstract long systemProfileHash(); 40 41 /** The found aggregate value. */ 42 @CopyAnnotations 43 @ColumnInfo(name = "aggregate_value") 44 @NonNull aggregateValue()45 abstract AggregateValue aggregateValue(); 46 47 /** 48 * Creates a {@link SystemProfileAndAggregateValue}. 49 * 50 * <p>Used by Room to instantiate objects. 51 */ 52 @NonNull create( long systemProfileHash, AggregateValue aggregateValue)53 static SystemProfileAndAggregateValue create( 54 long systemProfileHash, AggregateValue aggregateValue) { 55 return new AutoValue_SystemProfileAndAggregateValue(systemProfileHash, aggregateValue); 56 } 57 } 58