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 BooleanPolicyValue extends PolicyValue<Boolean> {
29 
BooleanPolicyValue(boolean value)30     public BooleanPolicyValue(boolean value) {
31         super(value);
32     }
33 
BooleanPolicyValue(Parcel source)34     private BooleanPolicyValue(Parcel source) {
35         this(source.readBoolean());
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         BooleanPolicyValue other = (BooleanPolicyValue) 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
toString()52     public String toString() {
53         return "BooleanPolicyValue { mValue= " + getValue() + " }";
54     }
55 
56     @Override
describeContents()57     public int describeContents() {
58         return 0;
59     }
60 
61     @Override
writeToParcel(@onNull Parcel dest, int flags)62     public void writeToParcel(@NonNull Parcel dest, int flags) {
63         dest.writeBoolean(getValue());
64     }
65 
66     @NonNull
67     public static final Creator<BooleanPolicyValue> CREATOR =
68             new Creator<BooleanPolicyValue>() {
69                 @Override
70                 public BooleanPolicyValue createFromParcel(Parcel source) {
71                     return new BooleanPolicyValue(source);
72                 }
73 
74                 @Override
75                 public BooleanPolicyValue[] newArray(int size) {
76                     return new BooleanPolicyValue[size];
77                 }
78             };
79 }
80