Debian Codegraph @

core/java/android/service/controls/templates/ControlTemplateWrapper.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 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.service.controls.templates;
18
19 import android.annotation.NonNull;
20 import android.os.Parcel;
21 import android.os.Parcelable;
22
23 import com.android.internal.util.Preconditions;
24
25 /**
26 * Wrapper for parceling/unparceling {@link ControlTemplate}.
27 * @hide
28 */
29 public final class ControlTemplateWrapper implements Parcelable {
30
31 private final @NonNull ControlTemplate mControlTemplate;
32
33 public ControlTemplateWrapper(@NonNull ControlTemplate template) {
34 Preconditions.checkNotNull(template);
35 mControlTemplate = template;
36 }
37
38 @Override
39 public int describeContents() {
40 return 0;
41 }
42
43 @NonNull
44 public ControlTemplate getWrappedTemplate() {
45 return mControlTemplate;
46 }
47
48 @Override
49 public void writeToParcel(@NonNull Parcel dest, int flags) {
50 dest.writeBundle(mControlTemplate.getDataBundle());
51 }
52
53 public static final @NonNull Creator<ControlTemplateWrapper> CREATOR =
54 new Creator<ControlTemplateWrapper>() {
55 @Override
56 public ControlTemplateWrapper createFromParcel(@NonNull Parcel source) {
57 return new ControlTemplateWrapper(
58 ControlTemplate.createTemplateFromBundle(source.readBundle()));
59 }
60
61 @Override
62 public ControlTemplateWrapper[] newArray(int size) {
63 return new ControlTemplateWrapper[size];
64 }
65 };
66 }