1 /**
2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3 * SPDX-License-Identifier: Apache-2.0.
4 */
5
6 #include <aws/codecommit/model/CommentsForComparedCommit.h>
7 #include <aws/core/utils/json/JsonSerializer.h>
8
9 #include <utility>
10
11 using namespace Aws::Utils::Json;
12 using namespace Aws::Utils;
13
14 namespace Aws
15 {
16 namespace CodeCommit
17 {
18 namespace Model
19 {
20
CommentsForComparedCommit()21 CommentsForComparedCommit::CommentsForComparedCommit() :
22 m_repositoryNameHasBeenSet(false),
23 m_beforeCommitIdHasBeenSet(false),
24 m_afterCommitIdHasBeenSet(false),
25 m_beforeBlobIdHasBeenSet(false),
26 m_afterBlobIdHasBeenSet(false),
27 m_locationHasBeenSet(false),
28 m_commentsHasBeenSet(false)
29 {
30 }
31
CommentsForComparedCommit(JsonView jsonValue)32 CommentsForComparedCommit::CommentsForComparedCommit(JsonView jsonValue) :
33 m_repositoryNameHasBeenSet(false),
34 m_beforeCommitIdHasBeenSet(false),
35 m_afterCommitIdHasBeenSet(false),
36 m_beforeBlobIdHasBeenSet(false),
37 m_afterBlobIdHasBeenSet(false),
38 m_locationHasBeenSet(false),
39 m_commentsHasBeenSet(false)
40 {
41 *this = jsonValue;
42 }
43
operator =(JsonView jsonValue)44 CommentsForComparedCommit& CommentsForComparedCommit::operator =(JsonView jsonValue)
45 {
46 if(jsonValue.ValueExists("repositoryName"))
47 {
48 m_repositoryName = jsonValue.GetString("repositoryName");
49
50 m_repositoryNameHasBeenSet = true;
51 }
52
53 if(jsonValue.ValueExists("beforeCommitId"))
54 {
55 m_beforeCommitId = jsonValue.GetString("beforeCommitId");
56
57 m_beforeCommitIdHasBeenSet = true;
58 }
59
60 if(jsonValue.ValueExists("afterCommitId"))
61 {
62 m_afterCommitId = jsonValue.GetString("afterCommitId");
63
64 m_afterCommitIdHasBeenSet = true;
65 }
66
67 if(jsonValue.ValueExists("beforeBlobId"))
68 {
69 m_beforeBlobId = jsonValue.GetString("beforeBlobId");
70
71 m_beforeBlobIdHasBeenSet = true;
72 }
73
74 if(jsonValue.ValueExists("afterBlobId"))
75 {
76 m_afterBlobId = jsonValue.GetString("afterBlobId");
77
78 m_afterBlobIdHasBeenSet = true;
79 }
80
81 if(jsonValue.ValueExists("location"))
82 {
83 m_location = jsonValue.GetObject("location");
84
85 m_locationHasBeenSet = true;
86 }
87
88 if(jsonValue.ValueExists("comments"))
89 {
90 Array<JsonView> commentsJsonList = jsonValue.GetArray("comments");
91 for(unsigned commentsIndex = 0; commentsIndex < commentsJsonList.GetLength(); ++commentsIndex)
92 {
93 m_comments.push_back(commentsJsonList[commentsIndex].AsObject());
94 }
95 m_commentsHasBeenSet = true;
96 }
97
98 return *this;
99 }
100
Jsonize() const101 JsonValue CommentsForComparedCommit::Jsonize() const
102 {
103 JsonValue payload;
104
105 if(m_repositoryNameHasBeenSet)
106 {
107 payload.WithString("repositoryName", m_repositoryName);
108
109 }
110
111 if(m_beforeCommitIdHasBeenSet)
112 {
113 payload.WithString("beforeCommitId", m_beforeCommitId);
114
115 }
116
117 if(m_afterCommitIdHasBeenSet)
118 {
119 payload.WithString("afterCommitId", m_afterCommitId);
120
121 }
122
123 if(m_beforeBlobIdHasBeenSet)
124 {
125 payload.WithString("beforeBlobId", m_beforeBlobId);
126
127 }
128
129 if(m_afterBlobIdHasBeenSet)
130 {
131 payload.WithString("afterBlobId", m_afterBlobId);
132
133 }
134
135 if(m_locationHasBeenSet)
136 {
137 payload.WithObject("location", m_location.Jsonize());
138
139 }
140
141 if(m_commentsHasBeenSet)
142 {
143 Array<JsonValue> commentsJsonList(m_comments.size());
144 for(unsigned commentsIndex = 0; commentsIndex < commentsJsonList.GetLength(); ++commentsIndex)
145 {
146 commentsJsonList[commentsIndex].AsObject(m_comments[commentsIndex].Jsonize());
147 }
148 payload.WithArray("comments", std::move(commentsJsonList));
149
150 }
151
152 return payload;
153 }
154
155 } // namespace Model
156 } // namespace CodeCommit
157 } // namespace Aws
158