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