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 
17 package android.app.admin;
18 
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.annotation.TestApi;
22 import android.os.Parcel;
23 import android.os.Parcelable;
24 
25 /**
26  * Class to identify a union resolution mechanism for flag policies, it's used to resolve the
27  * enforced policy when being set by multiple admins (see
28  * {@link PolicyState#getResolutionMechanism()}).
29  *
30  * @hide
31  */
32 @TestApi
33 public final class FlagUnion extends ResolutionMechanism<Integer> {
34 
35     /**
36      * Union resolution for policies represented as int flags which resolves as the union of all
37      * flags.
38      */
39     @NonNull
40     public static final FlagUnion FLAG_UNION = new FlagUnion();
41 
FlagUnion()42     private FlagUnion(){};
43 
44     @Override
equals(@ullable Object o)45     public boolean equals(@Nullable Object o) {
46         if (this == o) return true;
47         return o != null && getClass() == o.getClass();
48     }
49 
50     @Override
hashCode()51     public int hashCode() {
52         return 0;
53     }
54 
55     @Override
toString()56     public String toString() {
57         return "FlagUnion {}";
58     }
59 
60     @Override
describeContents()61     public int describeContents() {
62         return 0;
63     }
64 
65     @Override
writeToParcel(@onNull Parcel dest, int flags)66     public void writeToParcel(@NonNull Parcel dest, int flags) {}
67 
68     @NonNull
69     public static final Parcelable.Creator<FlagUnion> CREATOR =
70             new Parcelable.Creator<FlagUnion>() {
71                 @Override
72                 public FlagUnion createFromParcel(Parcel source) {
73                     return FLAG_UNION;
74                 }
75 
76                 @Override
77                 public FlagUnion[] newArray(int size) {
78                     return new FlagUnion[size];
79                 }
80             };
81 
82 }
83