Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / android / CHIPTool / app / src / main / java / com / google / chip / chiptool / commissioner / thread / internal / ThreadNetworkInfoHolder.java
1 /*
2  *   Copyright (c) 2020 Project CHIP Authors
3  *   All rights reserved.
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  */
18
19 package com.google.chip.chiptool.commissioner.thread.internal;
20
21 import android.os.Parcel;
22 import android.os.Parcelable;
23 import androidx.annotation.NonNull;
24 import com.google.chip.chiptool.commissioner.thread.BorderAgentInfo;
25 import com.google.chip.chiptool.commissioner.thread.ThreadNetworkInfo;
26 import java.util.ArrayList;
27
28 class ThreadNetworkInfoHolder implements Parcelable {
29   @NonNull private final ThreadNetworkInfo networkInfo;
30
31   @NonNull private final ArrayList<BorderAgentInfo> borderAgents;
32
33   public ThreadNetworkInfoHolder(BorderAgentInfo borderAgent) {
34     networkInfo = new ThreadNetworkInfo(borderAgent.networkName, borderAgent.extendedPanId);
35     borderAgents = new ArrayList<>();
36     borderAgents.add(borderAgent);
37   }
38
39   protected ThreadNetworkInfoHolder(Parcel in) {
40     networkInfo = in.readParcelable(ThreadNetworkInfo.class.getClassLoader());
41     borderAgents = in.createTypedArrayList(BorderAgentInfo.CREATOR);
42   }
43
44   public static final Creator<ThreadNetworkInfoHolder> CREATOR =
45       new Creator<ThreadNetworkInfoHolder>() {
46         @Override
47         public ThreadNetworkInfoHolder createFromParcel(Parcel in) {
48           return new ThreadNetworkInfoHolder(in);
49         }
50
51         @Override
52         public ThreadNetworkInfoHolder[] newArray(int size) {
53           return new ThreadNetworkInfoHolder[size];
54         }
55       };
56
57   public ThreadNetworkInfo getNetworkInfo() {
58     return networkInfo;
59   }
60
61   public ArrayList<BorderAgentInfo> getBorderAgents() {
62     return borderAgents;
63   }
64
65   @Override
66   public int describeContents() {
67     return 0;
68   }
69
70   @Override
71   public void writeToParcel(Parcel dest, int flags) {
72     dest.writeParcelable(networkInfo, flags);
73     dest.writeParcelableArray((BorderAgentInfo[]) borderAgents.toArray(), flags);
74   }
75 }