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 import com.google.cobalt.SystemProfile;
26 
27 /**
28  * Encapsulates one locally aggregated event that is required for generating observations.
29  *
30  * <p>Values are tagged with @ColumnInfo so {@link EventRecordAndSystemProfile} can be automatically
31  * read from tables.
32  */
33 @AutoValue
34 @CopyAnnotations
35 public abstract class EventRecordAndSystemProfile {
36     /** The system profile. */
37     @CopyAnnotations
38     @ColumnInfo(name = "system_profile")
39     @NonNull
systemProfile()40     public abstract SystemProfile systemProfile();
41 
42     /** The event vector. */
43     @CopyAnnotations
44     @ColumnInfo(name = "event_vector")
45     @NonNull
eventVector()46     public abstract EventVector eventVector();
47 
48     /** The found aggregate value. */
49     @CopyAnnotations
50     @ColumnInfo(name = "aggregate_value")
51     @NonNull
aggregateValue()52     public abstract AggregateValue aggregateValue();
53 
54     /**
55      * Creates a {@link EventRecordAndSystemProfile}.
56      *
57      * <p>Used by Room to instantiate objects.
58      */
59     @NonNull
create( SystemProfile systemProfile, EventVector eventVector, AggregateValue aggregateValue)60     public static EventRecordAndSystemProfile create(
61             SystemProfile systemProfile, EventVector eventVector, AggregateValue aggregateValue) {
62         return new AutoValue_EventRecordAndSystemProfile(
63                 systemProfile, eventVector, aggregateValue);
64     }
65 }
66