1/** 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16import { StringUtil } from '../../../../../../common/src/main/ets/util/StringUtil'; 17 18/** 19 * Contact List Data Structure Entity 20 */ 21export class ContactVo { 22 contactId: string; 23 namePrefix: string; 24 emptyNameData: string; 25 company: string; 26 position: string; 27 portraitColor: string; 28 show: boolean; 29 portraitPath: string; 30 nameSuffix: string; 31 phoneNum: string; 32 showName: string; 33 phoneNumbers: object[]; 34 name: NameVo; 35 title: string; 36 subTitle: string; 37 constructor(contactId: string, 38 namePrefix: string, 39 emptyNameData: string, 40 company: string, 41 position: string, 42 portraitColor: string, 43 show: boolean, 44 portraitPath: string, 45 phoneNum: string 46 ) { 47 this.contactId = contactId; 48 this.namePrefix = namePrefix; 49 this.emptyNameData = emptyNameData; 50 this.company = company; 51 this.position = position; 52 this.portraitColor = portraitColor; 53 this.show = show; 54 this.portraitPath = portraitPath; 55 this.phoneNum = phoneNum; 56 } 57 58 public setShowName() { 59 this.showName = !StringUtil.isEmpty(this.emptyNameData) ? this.emptyNameData : (!StringUtil.isEmpty(this.company) ? this.company : (!StringUtil.isEmpty(this.position) ? this.position : '')) 60 } 61 62 public setName(emptyNameData: string, namePrefix: string, nameSuffix: string) { 63 this.name = new NameVo(emptyNameData, namePrefix, nameSuffix); 64 } 65 66 public setphoneNumbers(phoneNumbers: object[]) { 67 this.phoneNumbers = phoneNumbers; 68 } 69 70 public setTitle(title: string) { 71 this.title = title; 72 } 73 74 public setSubTitle(subTitle: string) { 75 this.subTitle = subTitle; 76 } 77} 78 79export class NameVo { 80 fullName: string; 81 namePrefix: string; 82 nameSuffix: string; 83 searchTextStart: string; 84 searchTextMiddle: string; 85 searchTextEnd: string; 86 constructor(emptyNameData: string, namePrefix: string, nameSuffix: string) { 87 this.fullName = emptyNameData; 88 this.namePrefix = namePrefix; 89 this.nameSuffix = nameSuffix; 90 } 91}