1 /*
2  * Copyright (C) 2018 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.powermodel;
18 
19 class AppInfo {
20     private AttributionKey mAttribution;
21 
AppInfo()22     protected AppInfo() {
23     }
24 
hasPackage(String pkg)25     public boolean hasPackage(String pkg) {
26         return mAttribution.hasPackage(pkg);
27     }
28 
getAttribution()29     public AttributionKey getAttribution() {
30         return mAttribution;
31     }
32 
33     abstract static class Builder<APP extends AppInfo> {
34         private AttributionKey mAttribution;
35 
Builder()36         public Builder() {
37         }
38 
build()39         public abstract APP build();
40 
init(AppInfo app)41         protected void init(AppInfo app) {
42             if (mAttribution == null) {
43                 throw new RuntimeException("setAttribution(AttributionKey attribution) not called");
44             }
45             app.mAttribution = mAttribution;
46         }
47 
setAttribution(AttributionKey attribution)48         public void setAttribution(AttributionKey attribution) {
49             mAttribution = attribution;
50         }
51 
getAttribution()52         public AttributionKey getAttribution() {
53             return mAttribution;
54         }
55     }
56 }
57