Debian Codegraph @

core/java/android/app/cloudsearch/SearchResponse.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2022 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 package android.app.cloudsearch;
17
18 import android.annotation.IntDef;
19 import android.annotation.NonNull;
20 import android.annotation.SystemApi;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 import java.util.ArrayList;
25 import java.util.List;
26
27 /**
28 * A {@link SearchResponse} includes search results and associated meta information.
29 *
30 * @hide
31 */
32 @SystemApi
33 public final class SearchResponse implements Parcelable {
34 /** @hide */
35 @IntDef(prefix = {"SEARCH_STATUS_"},
36 value = {SEARCH_STATUS_UNKNOWN,
37 SEARCH_STATUS_OK,
38 SEARCH_STATUS_TIME_OUT,
39 SEARCH_STATUS_NO_INTERNET})
40 public @interface SearchStatusCode {
41 }
42
43 public static final int SEARCH_STATUS_UNKNOWN = -1;
44 public static final int SEARCH_STATUS_OK = 0;
45 public static final int SEARCH_STATUS_TIME_OUT = 1;
46 public static final int SEARCH_STATUS_NO_INTERNET = 2;
47
48 private SearchResponse() {
49 }
50
51 /** Gets the search status code. */
52 public int getStatusCode() {
53 return SEARCH_STATUS_UNKNOWN;
54 }
55
56 /** Gets the search provider package name. */
57 @NonNull
58 public String getSource() {
59 return "";
60 }
61
62 /** Gets the search results, which can be empty. */
63 @NonNull
64 public List<SearchResult> getSearchResults() {
65 return new ArrayList<SearchResult>();
66 }
67
68 /**
69 * Sets the search provider, and this will be set by the system server.
70 *
71 * @hide
72 */
73 public void setSource(@NonNull String source) {
74 }
75
76 /**
77 * @see Creator
78 */
79 @NonNull
80 public static final Creator<SearchResponse> CREATOR = new Creator<SearchResponse>() {
81 @Override
82 public SearchResponse createFromParcel(Parcel p) {
83 return new SearchResponse();
84 }
85
86 @Override
87 public SearchResponse[] newArray(int size) {
88 return new SearchResponse[size];
89 }
90 };
91
92 @Override
93 public void writeToParcel(@NonNull Parcel dest, int flags) {
94 }
95
96 @Override
97 public int describeContents() {
98 return 0;
99 }
100
101 @Override
102 public boolean equals(Object obj) {
103 return false;
104 }
105
106 @Override
107 public int hashCode() {
108 return 0;
109 }
110
111 /**
112 * Builder constructing SearchResponse.
113 *
114 * @hide
115 */
116 @SystemApi
117 public static final class Builder {
118 /**
119 * @param statusCode the search status code.
120 * @hide
121 */
122 @SystemApi
123 public Builder(@SearchStatusCode int statusCode) {
124 }
125
126 /** Sets the search status code. */
127 @NonNull
128 public Builder setStatusCode(@SearchStatusCode int statusCode) {
129 return this;
130 }
131
132 /**
133 * Sets the search provider, and this will be set by the system server.
134 *
135 * @hide
136 */
137 @NonNull
138 public Builder setSource(@NonNull String source) {
139 return this;
140 }
141
142 /** Sets the search results. */
143 @NonNull
144 public Builder setSearchResults(@NonNull List<SearchResult> searchResults) {
145 return this;
146 }
147
148 /** Builds a SearchResponse based-on the given parameters. */
149 @NonNull
150 public SearchResponse build() {
151 return new SearchResponse();
152 }
153 }
154 }