• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
37     private int methodCall;
38 
LogFields(int apiType, int uriType, boolean callerIsSyncAdapter, long startNanos)39     public LogFields(int apiType, int uriType, boolean callerIsSyncAdapter, long startNanos) {
40         this.apiType = apiType;
41         this.uriType = uriType;
42         this.callerIsSyncAdapter = callerIsSyncAdapter;
43         this.startNanos = startNanos;
44     }
45 
getApiType()46     public int getApiType() {
47         return apiType;
48     }
49 
getUriType()50     public int getUriType() {
51         return uriType;
52     }
53 
isCallerIsSyncAdapter()54     public boolean isCallerIsSyncAdapter() {
55         return callerIsSyncAdapter;
56     }
57 
getStartNanos()58     public long getStartNanos() {
59         return startNanos;
60     }
61 
getException()62     public Exception getException() {
63         return exception;
64     }
65 
getResultUri()66     public Uri getResultUri() {
67         return resultUri;
68     }
69 
getResultCount()70     public int getResultCount() {
71         return resultCount;
72     }
73 
getMethodCall()74     public int getMethodCall() {
75         return methodCall;
76     }
77 
78     public static final class Builder {
79         private int apiType;
80         private int uriType;
81         private boolean callerIsSyncAdapter;
82         private long startNanos;
83         private Exception exception;
84         private Uri resultUri;
85         private int resultCount;
86         private int methodCall;
87 
Builder()88         private Builder() {
89         }
90 
aLogFields()91         public static Builder aLogFields() {
92             return new Builder();
93         }
94 
setApiType(int apiType)95         public Builder setApiType(int apiType) {
96             this.apiType = apiType;
97             return this;
98         }
99 
setUriType(int uriType)100         public Builder setUriType(int uriType) {
101             this.uriType = uriType;
102             return this;
103         }
104 
setCallerIsSyncAdapter(boolean callerIsSyncAdapter)105         public Builder setCallerIsSyncAdapter(boolean callerIsSyncAdapter) {
106             this.callerIsSyncAdapter = callerIsSyncAdapter;
107             return this;
108         }
109 
setStartNanos(long startNanos)110         public Builder setStartNanos(long startNanos) {
111             this.startNanos = startNanos;
112             return this;
113         }
114 
setException(Exception exception)115         public Builder setException(Exception exception) {
116             this.exception = exception;
117             return this;
118         }
119 
setResultUri(Uri resultUri)120         public Builder setResultUri(Uri resultUri) {
121             this.resultUri = resultUri;
122             return this;
123         }
124 
setResultCount(int resultCount)125         public Builder setResultCount(int resultCount) {
126             this.resultCount = resultCount;
127             return this;
128         }
129 
setMethodCall(int methodCall)130         public Builder setMethodCall(int methodCall) {
131             this.methodCall = methodCall;
132             return this;
133         }
134 
build()135         public LogFields build() {
136             LogFields logFields = new LogFields(apiType, uriType, callerIsSyncAdapter, startNanos);
137             logFields.resultCount = this.resultCount;
138             logFields.exception = this.exception;
139             logFields.resultUri = this.resultUri;
140             logFields.methodCall = this.methodCall;
141             return logFields;
142         }
143     }
144 }
145