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 com.android.internal.pm.pkg.component;
18 
19 import android.annotation.NonNull;
20 import android.annotation.StringRes;
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 
24 import com.android.internal.annotations.VisibleForTesting;
25 import com.android.internal.util.DataClass;
26 
27 import java.util.ArrayList;
28 import java.util.List;
29 
30 /**
31  * A {@link android.R.styleable#AndroidManifestAttribution <attribution>} tag parsed from the
32  * manifest.
33  *
34  * @hide
35  */
36 @DataClass(genAidl = false, genSetters = true, genBuilder = false, genParcelable = true)
37 @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE)
38 public class ParsedAttributionImpl implements ParsedAttribution, Parcelable {
39 
40     /** Maximum amount of attributions per package */
41     static final int MAX_NUM_ATTRIBUTIONS = 400;
42 
43     /** Tag of the attribution */
44     private @NonNull String tag;
45 
46     /** User visible label fo the attribution */
47     private @StringRes int label;
48 
49     /** Ids of previously declared attributions this attribution inherits from */
50     private @NonNull List<String> inheritFrom;
51 
ParsedAttributionImpl()52     public ParsedAttributionImpl() {}
53 
54 
55 
56     // Code below generated by codegen v1.0.23.
57     //
58     // DO NOT MODIFY!
59     // CHECKSTYLE:OFF Generated code
60     //
61     // To regenerate run:
62     // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/com/android/internal/pm/pkg/component/ParsedAttributionImpl.java
63     //
64     // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
65     //   Settings > Editor > Code Style > Formatter Control
66     //@formatter:off
67 
68 
69     /**
70      * Creates a new ParsedAttributionImpl.
71      *
72      * @param tag
73      *   Tag of the attribution
74      * @param label
75      *   User visible label fo the attribution
76      * @param inheritFrom
77      *   Ids of previously declared attributions this attribution inherits from
78      */
79     @DataClass.Generated.Member
ParsedAttributionImpl( @onNull String tag, @StringRes int label, @NonNull List<String> inheritFrom)80     public ParsedAttributionImpl(
81             @NonNull String tag,
82             @StringRes int label,
83             @NonNull List<String> inheritFrom) {
84         this.tag = tag;
85         com.android.internal.util.AnnotationValidations.validate(
86                 NonNull.class, null, tag);
87         this.label = label;
88         com.android.internal.util.AnnotationValidations.validate(
89                 StringRes.class, null, label);
90         this.inheritFrom = inheritFrom;
91         com.android.internal.util.AnnotationValidations.validate(
92                 NonNull.class, null, inheritFrom);
93 
94         // onConstructed(); // You can define this method to get a callback
95     }
96 
97     /**
98      * Tag of the attribution
99      */
100     @DataClass.Generated.Member
getTag()101     public @NonNull String getTag() {
102         return tag;
103     }
104 
105     /**
106      * User visible label fo the attribution
107      */
108     @DataClass.Generated.Member
getLabel()109     public @StringRes int getLabel() {
110         return label;
111     }
112 
113     /**
114      * Ids of previously declared attributions this attribution inherits from
115      */
116     @DataClass.Generated.Member
getInheritFrom()117     public @NonNull List<String> getInheritFrom() {
118         return inheritFrom;
119     }
120 
121     /**
122      * Tag of the attribution
123      */
124     @DataClass.Generated.Member
setTag(@onNull String value)125     public @NonNull ParsedAttributionImpl setTag(@NonNull String value) {
126         tag = value;
127         com.android.internal.util.AnnotationValidations.validate(
128                 NonNull.class, null, tag);
129         return this;
130     }
131 
132     /**
133      * User visible label fo the attribution
134      */
135     @DataClass.Generated.Member
setLabel(@tringRes int value)136     public @NonNull ParsedAttributionImpl setLabel(@StringRes int value) {
137         label = value;
138         com.android.internal.util.AnnotationValidations.validate(
139                 StringRes.class, null, label);
140         return this;
141     }
142 
143     /**
144      * Ids of previously declared attributions this attribution inherits from
145      */
146     @DataClass.Generated.Member
setInheritFrom(@onNull List<String> value)147     public @NonNull ParsedAttributionImpl setInheritFrom(@NonNull List<String> value) {
148         inheritFrom = value;
149         com.android.internal.util.AnnotationValidations.validate(
150                 NonNull.class, null, inheritFrom);
151         return this;
152     }
153 
154     @Override
155     @DataClass.Generated.Member
writeToParcel(@onNull Parcel dest, int flags)156     public void writeToParcel(@NonNull Parcel dest, int flags) {
157         // You can override field parcelling by defining methods like:
158         // void parcelFieldName(Parcel dest, int flags) { ... }
159 
160         dest.writeString(tag);
161         dest.writeInt(label);
162         dest.writeStringList(inheritFrom);
163     }
164 
165     @Override
166     @DataClass.Generated.Member
describeContents()167     public int describeContents() { return 0; }
168 
169     /** @hide */
170     @SuppressWarnings({"unchecked", "RedundantCast"})
171     @DataClass.Generated.Member
ParsedAttributionImpl(@onNull Parcel in)172     protected ParsedAttributionImpl(@NonNull Parcel in) {
173         // You can override field unparcelling by defining methods like:
174         // static FieldType unparcelFieldName(Parcel in) { ... }
175 
176         String _tag = in.readString();
177         int _label = in.readInt();
178         List<String> _inheritFrom = new ArrayList<>();
179         in.readStringList(_inheritFrom);
180 
181         this.tag = _tag;
182         com.android.internal.util.AnnotationValidations.validate(
183                 NonNull.class, null, tag);
184         this.label = _label;
185         com.android.internal.util.AnnotationValidations.validate(
186                 StringRes.class, null, label);
187         this.inheritFrom = _inheritFrom;
188         com.android.internal.util.AnnotationValidations.validate(
189                 NonNull.class, null, inheritFrom);
190 
191         // onConstructed(); // You can define this method to get a callback
192     }
193 
194     @DataClass.Generated.Member
195     public static final @NonNull Parcelable.Creator<ParsedAttributionImpl> CREATOR
196             = new Parcelable.Creator<ParsedAttributionImpl>() {
197         @Override
198         public ParsedAttributionImpl[] newArray(int size) {
199             return new ParsedAttributionImpl[size];
200         }
201 
202         @Override
203         public ParsedAttributionImpl createFromParcel(@NonNull Parcel in) {
204             return new ParsedAttributionImpl(in);
205         }
206     };
207 
208     @DataClass.Generated(
209             time = 1701338881658L,
210             codegenVersion = "1.0.23",
211             sourceFile = "frameworks/base/core/java/com/android/internal/pm/pkg/component/ParsedAttributionImpl.java",
212             inputSignatures = "static final  int MAX_NUM_ATTRIBUTIONS\nprivate @android.annotation.NonNull java.lang.String tag\nprivate @android.annotation.StringRes int label\nprivate @android.annotation.NonNull java.util.List<java.lang.String> inheritFrom\nclass ParsedAttributionImpl extends java.lang.Object implements [com.android.internal.pm.pkg.component.ParsedAttribution, android.os.Parcelable]\n@com.android.internal.util.DataClass(genAidl=false, genSetters=true, genBuilder=false, genParcelable=true)")
213     @Deprecated
__metadata()214     private void __metadata() {}
215 
216 
217     //@formatter:on
218     // End of generated code
219 
220 }
221