1e75ebbc8Sopenharmony_ci/*
2e75ebbc8Sopenharmony_ci * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3e75ebbc8Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4e75ebbc8Sopenharmony_ci * you may not use this file except in compliance with the License.
5e75ebbc8Sopenharmony_ci * You may obtain a copy of the License at
6e75ebbc8Sopenharmony_ci *
7e75ebbc8Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8e75ebbc8Sopenharmony_ci *
9e75ebbc8Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10e75ebbc8Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11e75ebbc8Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12e75ebbc8Sopenharmony_ci * See the License for the specific language governing permissions and
13e75ebbc8Sopenharmony_ci * limitations under the License.
14e75ebbc8Sopenharmony_ci */
15e75ebbc8Sopenharmony_ci
16e75ebbc8Sopenharmony_ciexport default class CheckEmptyUtils {
17e75ebbc8Sopenharmony_ci
18e75ebbc8Sopenharmony_ci  /**
19e75ebbc8Sopenharmony_ci     * Check obj is empty.
20e75ebbc8Sopenharmony_ci     *
21e75ebbc8Sopenharmony_ci     * @param {Object} obj need checked object
22e75ebbc8Sopenharmony_ci     * @return {boolean} true(empty)
23e75ebbc8Sopenharmony_ci     */
24e75ebbc8Sopenharmony_ci  static isEmpty(obj) {
25e75ebbc8Sopenharmony_ci    return (typeof obj === 'undefined' || obj === null || obj === '' || Object.keys(obj).length === 0);
26e75ebbc8Sopenharmony_ci  }
27e75ebbc8Sopenharmony_ci
28e75ebbc8Sopenharmony_ci  /**
29e75ebbc8Sopenharmony_ci     * Check str is empty.
30e75ebbc8Sopenharmony_ci     *
31e75ebbc8Sopenharmony_ci     * @param {string} str need checked string
32e75ebbc8Sopenharmony_ci     * @return {boolean} true(empty)
33e75ebbc8Sopenharmony_ci     */
34e75ebbc8Sopenharmony_ci  static checkStrIsEmpty(str) {
35e75ebbc8Sopenharmony_ci    return str.trim().length === 0;
36e75ebbc8Sopenharmony_ci  }
37e75ebbc8Sopenharmony_ci
38e75ebbc8Sopenharmony_ci  /**
39e75ebbc8Sopenharmony_ci     * Check array is empty.
40e75ebbc8Sopenharmony_ci     *
41e75ebbc8Sopenharmony_ci     * @param {Array} arr need checked array
42e75ebbc8Sopenharmony_ci     * @return {boolean} true(empty)
43e75ebbc8Sopenharmony_ci     */
44e75ebbc8Sopenharmony_ci  static isEmptyArr(arr) {
45e75ebbc8Sopenharmony_ci    return arr.length === 0;
46e75ebbc8Sopenharmony_ci  }
47e75ebbc8Sopenharmony_ci}