Debian Codegraph @

core/java/android/content/om/OverlayIdentifier.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.content.om;
18
19 import android.annotation.NonNull;
20 import android.annotation.Nullable;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23
24 import com.android.internal.util.DataClass;
25
26 import java.util.Objects;
27
28 /**
29 * A key used to uniquely identify a Runtime Resource Overlay (RRO).
30 *
31 * An overlay always belongs to a package and may optionally have a name associated with it.
32 * The name helps uniquely identify a particular overlay within a package.
33 * @hide
34 */
35 /** @hide */
36 @DataClass(genConstructor = false, genBuilder = false, genHiddenBuilder = false,
37 genEqualsHashCode = true, genToString = false)
38 public class OverlayIdentifier implements Parcelable {
39 /**
40 * The package name containing or owning the overlay.
41 */
42 @Nullable
43 private final String mPackageName;
44
45 /**
46 * The unique name within the package of the overlay.
47 */
48 @Nullable
49 private final String mOverlayName;
50
51 /**
52 * Creates an identifier from a package and unique name within the package.
53 *
54 * @param packageName the package containing or owning the overlay
55 * @param overlayName the unique name of the overlay within the package
56 */
57 public OverlayIdentifier(@NonNull String packageName, @Nullable String overlayName) {
58 mPackageName = packageName;
59 mOverlayName = overlayName;
60 }
61
62 /**
63 * Creates an identifier for an overlay without a name.
64 *
65 * @param packageName the package containing or owning the overlay
66 */
67 public OverlayIdentifier(@NonNull String packageName) {
68 mPackageName = packageName;
69 mOverlayName = null;
70 }
71
72 @Override
73 public String toString() {
74 return mOverlayName == null ? mPackageName : mPackageName + ":" + mOverlayName;
75 }
76
77 /** @hide */
78 public static OverlayIdentifier fromString(@NonNull String text) {
79 final String[] parts = text.split(":", 2);
80 if (parts.length == 2) {
81 return new OverlayIdentifier(parts[0], parts[1]);
82 } else {
83 return new OverlayIdentifier(parts[0]);
84 }
85 }
86
87
88
89 // Code below generated by codegen v1.0.22.
90 //
91 // DO NOT MODIFY!
92 // CHECKSTYLE:OFF Generated code
93 //
94 // To regenerate run:
95 // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/content/om/OverlayIdentifier.java
96 //
97 // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
98 // Settings > Editor > Code Style > Formatter Control
99 //@formatter:off
100
101
102 /**
103 * Retrieves the package name containing or owning the overlay.
104 */
105 @DataClass.Generated.Member
106 public @Nullable String getPackageName() {
107 return mPackageName;
108 }
109
110 /**
111 * Retrieves the unique name within the package of the overlay.
112 */
113 @DataClass.Generated.Member
114 public @Nullable String getOverlayName() {
115 return mOverlayName;
116 }
117
118 @Override
119 @DataClass.Generated.Member
120 public boolean equals(@Nullable Object o) {
121 // You can override field equality logic by defining either of the methods like:
122 // boolean fieldNameEquals(OverlayIdentifier other) { ... }
123 // boolean fieldNameEquals(FieldType otherValue) { ... }
124
125 if (this == o) return true;
126 if (o == null || getClass() != o.getClass()) return false;
127 @SuppressWarnings("unchecked")
128 OverlayIdentifier that = (OverlayIdentifier) o;
129 //noinspection PointlessBooleanExpression
130 return true
131 && Objects.equals(mPackageName, that.mPackageName)
132 && Objects.equals(mOverlayName, that.mOverlayName);
133 }
134
135 @Override
136 @DataClass.Generated.Member
137 public int hashCode() {
138 // You can override field hashCode logic by defining methods like:
139 // int fieldNameHashCode() { ... }
140
141 int _hash = 1;
142 _hash = 31 * _hash + Objects.hashCode(mPackageName);
143 _hash = 31 * _hash + Objects.hashCode(mOverlayName);
144 return _hash;
145 }
146
147 @Override
148 @DataClass.Generated.Member
149 public void writeToParcel(@NonNull Parcel dest, int flags) {
150 // You can override field parcelling by defining methods like:
151 // void parcelFieldName(Parcel dest, int flags) { ... }
152
153 byte flg = 0;
154 if (mPackageName != null) flg |= 0x1;
155 if (mOverlayName != null) flg |= 0x2;
156 dest.writeByte(flg);
157 if (mPackageName != null) dest.writeString(mPackageName);
158 if (mOverlayName != null) dest.writeString(mOverlayName);
159 }
160
161 @Override
162 @DataClass.Generated.Member
163 public int describeContents() { return 0; }
164
165 /** @hide */
166 @SuppressWarnings({"unchecked", "RedundantCast"})
167 @DataClass.Generated.Member
168 protected OverlayIdentifier(@NonNull Parcel in) {
169 // You can override field unparcelling by defining methods like:
170 // static FieldType unparcelFieldName(Parcel in) { ... }
171
172 byte flg = in.readByte();
173 String packageName = (flg & 0x1) == 0 ? null : in.readString();
174 String overlayName = (flg & 0x2) == 0 ? null : in.readString();
175
176 this.mPackageName = packageName;
177 this.mOverlayName = overlayName;
178
179 // onConstructed(); // You can define this method to get a callback
180 }
181
182 @DataClass.Generated.Member
183 public static final @NonNull Parcelable.Creator<OverlayIdentifier> CREATOR
184 = new Parcelable.Creator<OverlayIdentifier>() {
185 @Override
186 public OverlayIdentifier[] newArray(int size) {
187 return new OverlayIdentifier[size];
188 }
189
190 @Override
191 public OverlayIdentifier createFromParcel(@NonNull Parcel in) {
192 return new OverlayIdentifier(in);
193 }
194 };
195
196 @DataClass.Generated(
197 time = 1612482438728L,
198 codegenVersion = "1.0.22",
199 sourceFile = "frameworks/base/core/java/android/content/om/OverlayIdentifier.java",
200 inputSignatures = "private final @android.annotation.Nullable java.lang.String mPackageName\nprivate final @android.annotation.Nullable java.lang.String mOverlayName\npublic @java.lang.Override java.lang.String toString()\npublic static android.content.om.OverlayIdentifier fromString(java.lang.String)\nclass OverlayIdentifier extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genConstructor=false, genBuilder=false, genHiddenBuilder=false, genEqualsHashCode=true, genToString=false)")
201 @Deprecated
202 private void __metadata() {}
203
204
205 //@formatter:on
206 // End of generated code
207
208 }