1/*
2 * Copyright (c) 2021 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
16#ifndef BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_TIME_H
17#define BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_TIME_H
18
19#include "notification_json_convert.h"
20#include "parcel.h"
21#include <cstdint>
22#include <string>
23
24namespace OHOS {
25namespace Notification {
26class NotificationTime : public Parcelable, public NotificationJsonConvertionBase {
27public:
28    NotificationTime() = default;
29
30    ~NotificationTime() = default;
31
32    /**
33     * @brief Obtains the initialTime.
34     *
35     * @return Returns the initialTime.
36     */
37    int32_t GetInitialTime() const;
38
39    void SetInitialTime(int32_t time);
40
41    /**
42     * @brief Obtains isCountDown flag.
43     *
44     * @return Returns the isCountDown flag.
45     */
46    bool GetIsCountDown() const;
47
48    void SetIsCountDown(bool flag);
49
50    /**
51     * @brief Obtains isPaused flag.
52     *
53     * @return Returns the isPaused flag.
54     */
55    bool GetIsPaused() const;
56
57    void SetIsPaused(bool flag);
58
59    /**
60     * @brief Obtains isInTitle flag.
61     *
62     * @return Returns the isInTitle flag.
63     */
64    bool GetIsInTitle() const;
65
66    void SetIsInTitle(bool flag);
67
68    /**
69     * @brief Returns a string representation of the object.
70     *
71     * @return Returns a string representation of the object.
72     */
73    std::string Dump();
74
75    /**
76     * @brief Converts a NotificationTime object into a Json.
77     *
78     * @param jsonObject Indicates the Json object.
79     * @return Returns true if succeed; returns false otherwise.
80     */
81    bool ToJson(nlohmann::json &jsonObject) const override;
82
83    /**
84     * @brief Creates a NotificationTime object from a Json.
85     *
86     * @param jsonObject Indicates the Json object.
87     * @return Returns the NotificationConversationalMessage.
88     */
89    static NotificationTime *FromJson(const nlohmann::json &jsonObject);
90
91    /**
92     * @brief Marshal a object into a Parcel.
93     *
94     * @param parcel Indicates the object into the parcel.
95     * @return Returns true if succeed; returns false otherwise.
96     */
97    virtual bool Marshalling(Parcel &parcel) const override;
98
99    /**
100     * @brief Unmarshal object from a Parcel.
101     *
102     * @param parcel Indicates the parcel object.
103     * @return Returns the NotificationTime.
104     */
105    static NotificationTime *Unmarshalling(Parcel &parcel);
106
107private:
108    /**
109     * @brief Read a NotificationTime object from a Parcel.
110     *
111     * @param parcel Indicates the parcel object.
112     * @return Returns true if succeed; returns false otherwise.
113     */
114    bool ReadFromParcel(Parcel &parcel);
115
116private:
117    int32_t initialTime_ {0};
118    bool isCountDown_ {false};
119    bool isPaused_ {false};
120    bool isInTitle_ {false};
121};
122}  // namespace Notification
123}  // namespace OHOS
124
125#endif  // BASE_NOTIFICATION_DISTRIBUTED_NOTIFICATION_SERVICE_INTERFACES_INNER_API_TIME_H