1 /*
2  * Copyright (C) 2024 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.server.companion.association;
18 
19 import android.companion.AssociationInfo;
20 
21 import java.util.ArrayList;
22 import java.util.List;
23 
24 /**
25  * Represents associations per user. Should be only used by Association stores.
26  */
27 public class Associations {
28 
29     private int mVersion = 0;
30 
31     private List<AssociationInfo> mAssociations = new ArrayList<>();
32 
33     private int mMaxId = 0;
34 
Associations()35     public Associations() {
36     }
37 
setVersion(int version)38     public void setVersion(int version) {
39         mVersion = version;
40     }
41 
42     /**
43      * Add an association.
44      */
addAssociation(AssociationInfo association)45     public void addAssociation(AssociationInfo association) {
46         mAssociations.add(association);
47     }
48 
setMaxId(int maxId)49     public void setMaxId(int maxId) {
50         mMaxId = maxId;
51     }
52 
setAssociations(List<AssociationInfo> associations)53     public void setAssociations(List<AssociationInfo> associations) {
54         mAssociations = List.copyOf(associations);
55     }
56 
getVersion()57     public int getVersion() {
58         return mVersion;
59     }
60 
getMaxId()61     public int getMaxId() {
62         return mMaxId;
63     }
64 
getAssociations()65     public List<AssociationInfo> getAssociations() {
66         return mAssociations;
67     }
68 }
69