• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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 */
15import { BasicDiffInfo } from '../../typedef/diff/ApiInfoDiff';
16import { FunctionUtils } from '../../utils/FunctionUtils';
17
18/**
19 * 使用syscap中的关键字段匹配子系统S
20 */
21export class SyscapProcessorHelper {
22  static matchSubsystem(diffInfo: BasicDiffInfo): string | undefined {
23    const subsystemMap: Map<string, string> = FunctionUtils.readSubsystemFile().subsystemMap;
24    const syscapField: string = SyscapProcessorHelper.getSyscapField(diffInfo);
25    if (syscapField) {
26      return subsystemMap.get(syscapField);
27    }
28    return 'NA';
29  }
30
31  static getSyscapField(diffInfo: BasicDiffInfo): string {
32    const newSyscap: string = diffInfo.getNewSyscapField();
33    if (newSyscap) {
34      return newSyscap;
35    }
36    const oldSyscap: string = diffInfo.getOldSyscapField();
37    if (oldSyscap) {
38      return oldSyscap;
39    }
40    return '';
41  }
42
43  static getSingleKitInfo(data: BasicDiffInfo): string {
44    if (data.getNewKitInfo() !== '') {
45      return data.getNewKitInfo();
46    }
47    return data.getOldKitInfo();
48  }
49}