1 /*
2  * Copyright (C) 2015 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 package com.android.messaging.datamodel.media;
17 
18 import android.accounts.Account;
19 import androidx.collection.ArrayMap;
20 
21 import com.android.vcard.VCardEntry;
22 import com.android.vcard.VCardProperty;
23 
24 import java.util.Map;
25 
26 /**
27  * Class which extends VCardEntry to add support for unknown properties.  Currently there is a TODO
28  * to add this in the VCardEntry code, but we have to extend it to add the needed support
29  */
30 public class CustomVCardEntry extends VCardEntry {
31     // List of properties keyed by their name for easy lookup
32     private final Map<String, VCardProperty> mAllProperties;
33 
CustomVCardEntry(int vCardType, Account account)34     public CustomVCardEntry(int vCardType, Account account) {
35         super(vCardType, account);
36         mAllProperties = new ArrayMap<String, VCardProperty>();
37     }
38 
39     @Override
addProperty(VCardProperty property)40     public void addProperty(VCardProperty property) {
41         super.addProperty(property);
42         mAllProperties.put(property.getName(), property);
43     }
44 
getProperty(String name)45     public VCardProperty getProperty(String name) {
46         return mAllProperties.get(name);
47     }
48 }
49