Debian Codegraph @

core/java/android/service/autofill/SavedDatasetsInfo.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2021 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 android.service.autofill;
18
19 import android.annotation.IntRange;
20 import android.annotation.NonNull;
21 import android.annotation.StringDef;
22
23 import com.android.internal.util.DataClass;
24
25 import java.lang.annotation.Retention;
26 import java.lang.annotation.RetentionPolicy;
27
28 /**
29 * A result returned from
30 * {@link AutofillService#onSavedDatasetsInfoRequest(SavedDatasetsInfoCallback)}.
31 */
32 @DataClass(
33 genToString = true,
34 genHiddenConstDefs = true,
35 genEqualsHashCode = true)
36 public final class SavedDatasetsInfo {
37
38 /**
39 * Any other type of datasets.
40 */
41 public static final String TYPE_OTHER = "other";
42
43 /**
44 * Datasets such as login credentials.
45 */
46 public static final String TYPE_PASSWORDS = "passwords";
47
48 /**
49 * The type of the datasets that this info is about.
50 */
51 @NonNull
52 @Type
53 private final String mType;
54
55 /**
56 * The number of datasets of {@link #getType() this type} that the user has saved to the
57 * service.
58 */
59 @IntRange(from = 0)
60 private final int mCount;
61
62
63 // Code below generated by codegen v1.0.22.
64 //
65 // DO NOT MODIFY!
66 // CHECKSTYLE:OFF Generated code
67 //
68 // To regenerate run:
69 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/SavedDatasetsInfo.java
70 //
71 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
72 // Settings > Editor > Code Style > Formatter Control
73 //@formatter:off
74
75
76 /** @hide */
77 @StringDef(prefix = "TYPE_", value = {
78 TYPE_OTHER,
79 TYPE_PASSWORDS
80 })
81 @Retention(RetentionPolicy.SOURCE)
82 @DataClass.Generated.Member
83 public @interface Type {}
84
85 /**
86 * Creates a new SavedDatasetsInfo.
87 *
88 * @param type
89 * The type of the datasets.
90 * @param count
91 * The number of datasets of this type that the user has saved to the service.
92 */
93 @DataClass.Generated.Member
94 public SavedDatasetsInfo(
95 @NonNull @Type String type,
96 @IntRange(from = 0) int count) {
97 this.mType = type;
98
99 if (!(java.util.Objects.equals(mType, TYPE_OTHER))
100 && !(java.util.Objects.equals(mType, TYPE_PASSWORDS))) {
101 throw new java.lang.IllegalArgumentException(
102 "type was " + mType + " but must be one of: "
103 + "TYPE_OTHER(" + TYPE_OTHER + "), "
104 + "TYPE_PASSWORDS(" + TYPE_PASSWORDS + ")");
105 }
106
107 com.android.internal.util.AnnotationValidations.validate(
108 NonNull.class, null, mType);
109 this.mCount = count;
110 com.android.internal.util.AnnotationValidations.validate(
111 IntRange.class, null, mCount,
112 "from", 0);
113
114 // onConstructed(); // You can define this method to get a callback
115 }
116
117 /**
118 * The type of the datasets.
119 */
120 @DataClass.Generated.Member
121 public @NonNull @Type String getType() {
122 return mType;
123 }
124
125 /**
126 * The number of datasets of this type that the user has saved to the service.
127 */
128 @DataClass.Generated.Member
129 public @IntRange(from = 0) int getCount() {
130 return mCount;
131 }
132
133 @Override
134 @DataClass.Generated.Member
135 public String toString() {
136 // You can override field toString logic by defining methods like:
137 // String fieldNameToString() { ... }
138
139 return "SavedDatasetsInfo { " +
140 "type = " + mType + ", " +
141 "count = " + mCount +
142 " }";
143 }
144
145 @Override
146 @DataClass.Generated.Member
147 public boolean equals(@android.annotation.Nullable Object o) {
148 // You can override field equality logic by defining either of the methods like:
149 // boolean fieldNameEquals(SavedDatasetsInfo other) { ... }
150 // boolean fieldNameEquals(FieldType otherValue) { ... }
151
152 if (this == o) return true;
153 if (o == null || getClass() != o.getClass()) return false;
154 @SuppressWarnings("unchecked")
155 SavedDatasetsInfo that = (SavedDatasetsInfo) o;
156 //noinspection PointlessBooleanExpression
157 return true
158 && java.util.Objects.equals(mType, that.mType)
159 && mCount == that.mCount;
160 }
161
162 @Override
163 @DataClass.Generated.Member
164 public int hashCode() {
165 // You can override field hashCode logic by defining methods like:
166 // int fieldNameHashCode() { ... }
167
168 int _hash = 1;
169 _hash = 31 * _hash + java.util.Objects.hashCode(mType);
170 _hash = 31 * _hash + mCount;
171 return _hash;
172 }
173
174 @DataClass.Generated(
175 time = 1615325704446L,
176 codegenVersion = "1.0.22",
177 sourceFile = "frameworks/base/core/java/android/service/autofill/SavedDatasetsInfo.java",
178 inputSignatures = "public static final java.lang.String TYPE_OTHER\npublic static final java.lang.String TYPE_PASSWORDS\nprivate final @android.annotation.NonNull @android.service.autofill.SavedDatasetsInfo.Type java.lang.String mType\nprivate final @android.annotation.IntRange int mCount\nclass SavedDatasetsInfo extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstDefs=true, genEqualsHashCode=true)")
179 @Deprecated
180 private void __metadata() {}
181
182
183 //@formatter:on
184 // End of generated code
185
186 }