1 /*
2  * Copyright (C) 2023 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.app.admin;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 
23 import java.util.Objects;
24 
25 /**
26  * @hide
27  */
28 public final class StringPolicyValue extends PolicyValue<String> {
29 
StringPolicyValue(@onNull String value)30     public StringPolicyValue(@NonNull String value) {
31         super(value);
32     }
33 
StringPolicyValue(Parcel source)34     private StringPolicyValue(Parcel source) {
35         super(source.readString());
36     }
37 
38     @Override
equals(@ullable Object o)39     public boolean equals(@Nullable Object o) {
40         if (this == o) return true;
41         if (o == null || getClass() != o.getClass()) return false;
42         StringPolicyValue other = (StringPolicyValue) o;
43         return Objects.equals(getValue(), other.getValue());
44     }
45 
46     @Override
hashCode()47     public int hashCode() {
48         return Objects.hash(getValue());
49     }
50 
51     @Override
describeContents()52     public int describeContents() {
53         return 0;
54     }
55 
56     @Override
toString()57     public String toString() {
58         return "StringPolicyValue { " + getValue() + " }";
59     }
60 
61     @Override
writeToParcel(@onNull Parcel dest, int flags)62     public void writeToParcel(@NonNull Parcel dest, int flags) {
63         dest.writeString(getValue());
64     }
65 
66     @NonNull
67     public static final Creator<StringPolicyValue> CREATOR = new Creator<StringPolicyValue>() {
68                 @Override
69                 public StringPolicyValue createFromParcel(Parcel source) {
70                     return new StringPolicyValue(source);
71                 }
72 
73                 @Override
74                 public StringPolicyValue[] newArray(int size) {
75                     return new StringPolicyValue[size];
76                 }
77             };
78 }
79