1 /*
2  * Copyright (C) 2020 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.providers.contacts.util;
18 
19 import android.net.Uri;
20 
21 public final class LogFields {
22 
23     private final int apiType;
24 
25     private final int uriType;
26 
27     private final boolean callerIsSyncAdapter;
28 
29     private final long startNanos;
30 
31     private Exception exception;
32 
33     private Uri resultUri;
34 
35     private int resultCount;
36 
LogFields(int apiType, int uriType, boolean callerIsSyncAdapter, long startNanos)37     public LogFields(int apiType, int uriType, boolean callerIsSyncAdapter, long startNanos) {
38         this.apiType = apiType;
39         this.uriType = uriType;
40         this.callerIsSyncAdapter = callerIsSyncAdapter;
41         this.startNanos = startNanos;
42     }
43 
getApiType()44     public int getApiType() {
45         return apiType;
46     }
47 
getUriType()48     public int getUriType() {
49         return uriType;
50     }
51 
isCallerIsSyncAdapter()52     public boolean isCallerIsSyncAdapter() {
53         return callerIsSyncAdapter;
54     }
55 
getStartNanos()56     public long getStartNanos() {
57         return startNanos;
58     }
59 
getException()60     public Exception getException() {
61         return exception;
62     }
63 
getResultUri()64     public Uri getResultUri() {
65         return resultUri;
66     }
67 
getResultCount()68     public int getResultCount() {
69         return resultCount;
70     }
71 
72     public static final class Builder {
73         private int apiType;
74         private int uriType;
75         private boolean callerIsSyncAdapter;
76         private long startNanos;
77         private Exception exception;
78         private Uri resultUri;
79         private int resultCount;
80 
Builder()81         private Builder() {
82         }
83 
aLogFields()84         public static Builder aLogFields() {
85             return new Builder();
86         }
87 
setApiType(int apiType)88         public Builder setApiType(int apiType) {
89             this.apiType = apiType;
90             return this;
91         }
92 
setUriType(int uriType)93         public Builder setUriType(int uriType) {
94             this.uriType = uriType;
95             return this;
96         }
97 
setCallerIsSyncAdapter(boolean callerIsSyncAdapter)98         public Builder setCallerIsSyncAdapter(boolean callerIsSyncAdapter) {
99             this.callerIsSyncAdapter = callerIsSyncAdapter;
100             return this;
101         }
102 
setStartNanos(long startNanos)103         public Builder setStartNanos(long startNanos) {
104             this.startNanos = startNanos;
105             return this;
106         }
107 
setException(Exception exception)108         public Builder setException(Exception exception) {
109             this.exception = exception;
110             return this;
111         }
112 
setResultUri(Uri resultUri)113         public Builder setResultUri(Uri resultUri) {
114             this.resultUri = resultUri;
115             return this;
116         }
117 
setResultCount(int resultCount)118         public Builder setResultCount(int resultCount) {
119             this.resultCount = resultCount;
120             return this;
121         }
122 
build()123         public LogFields build() {
124             LogFields logFields = new LogFields(apiType, uriType, callerIsSyncAdapter, startNanos);
125             logFields.resultCount = this.resultCount;
126             logFields.exception = this.exception;
127             logFields.resultUri = this.resultUri;
128             return logFields;
129         }
130     }
131 }
132