1 /*
2  * Copyright 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 
17 package android.credentials;
18 
19 import static java.util.Objects.requireNonNull;
20 
21 import android.annotation.NonNull;
22 import android.os.Bundle;
23 import android.os.Parcel;
24 import android.os.Parcelable;
25 
26 import com.android.internal.util.AnnotationValidations;
27 
28 /**
29  * A request class for clearing a user's credential state from the credential providers.
30  */
31 public final class ClearCredentialStateRequest implements Parcelable {
32 
33     /** The request data. */
34     @NonNull
35     private final Bundle mData;
36 
37     /** Returns the request data. */
38     @NonNull
getData()39     public Bundle getData() {
40         return mData;
41     }
42 
43     @Override
writeToParcel(@onNull Parcel dest, int flags)44     public void writeToParcel(@NonNull Parcel dest, int flags) {
45         dest.writeBundle(mData);
46     }
47 
48     @Override
describeContents()49     public int describeContents() {
50         return 0;
51     }
52 
53     @Override
toString()54     public String toString() {
55         return "ClearCredentialStateRequest {data=" + mData + "}";
56     }
57 
58     /**
59      * Constructs a {@link ClearCredentialStateRequest}.
60      *
61      * @param data the request data
62      */
ClearCredentialStateRequest(@onNull Bundle data)63     public ClearCredentialStateRequest(@NonNull Bundle data) {
64         mData = requireNonNull(data, "data must not be null");
65     }
66 
ClearCredentialStateRequest(@onNull Parcel in)67     private ClearCredentialStateRequest(@NonNull Parcel in) {
68         Bundle data = in.readBundle();
69         mData = data;
70         AnnotationValidations.validate(NonNull.class, null, mData);
71     }
72 
73     public static final @NonNull Creator<ClearCredentialStateRequest> CREATOR =
74             new Creator<ClearCredentialStateRequest>() {
75         @Override
76         public ClearCredentialStateRequest[] newArray(int size) {
77             return new ClearCredentialStateRequest[size];
78         }
79 
80         @Override
81         public ClearCredentialStateRequest createFromParcel(@NonNull Parcel in) {
82             return new ClearCredentialStateRequest(in);
83         }
84     };
85 }
86