blob: 770923656a89e0418a9543177057103dfdb1ca03 [file] [log] [blame]
lishuai91d986c2015-07-28 09:45:20 +08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.ovsdb.rfc.message;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20import java.util.List;
21
22import org.onosproject.ovsdb.rfc.notation.Row;
23import org.onosproject.ovsdb.rfc.notation.UUID;
24
25import com.fasterxml.jackson.annotation.JsonIgnore;
26import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
27import com.fasterxml.jackson.annotation.JsonProperty;
28
29/**
30 * All results of ovs table operations. refer to RFC7047 5.2.
31 */
32@JsonIgnoreProperties(ignoreUnknown = true)
33public final class OperationResult {
34 private int count;
35 @JsonIgnore
36 private UUID uuid;
37 private List<Row> rows;
38 private String error;
39 private String details;
40
41 /**
42 * Constructs a OperationResult object. When JsonNode is converted into
43 * OperationResult, need this constructor and also need setter method.
44 */
45 public OperationResult() {
46 }
47
48 /**
49 * Constructs a OperationResult object.
50 * @param rows List of Row entity
51 */
52 public OperationResult(List<Row> rows) {
lishuai2f197432015-07-31 16:27:58 +080053 checkNotNull(rows, "rows cannot be null");
lishuai91d986c2015-07-28 09:45:20 +080054 this.rows = rows;
55 }
56
57 /**
58 * Constructs a OperationResult object.
59 * @param count the count node of result
60 * @param uuid UUID entity
61 * @param rows List of Row entity
62 * @param error error message
63 * @param details details of error message
64 */
65 public OperationResult(int count, UUID uuid, List<Row> rows, String error,
66 String details) {
lishuai2f197432015-07-31 16:27:58 +080067 checkNotNull(uuid, "uuid cannot be null");
68 checkNotNull(rows, "rows cannot be null");
69 checkNotNull(error, "error cannot be null");
70 checkNotNull(details, "details cannot be null");
lishuai91d986c2015-07-28 09:45:20 +080071 this.count = count;
72 this.uuid = uuid;
73 this.rows = rows;
74 this.error = error;
75 this.details = details;
76 }
77
78 /**
79 * Return count.
80 * @return count
81 */
82 public int getCount() {
83 return count;
84 }
85
86 /**
87 * Set count value.
88 * @param count the Operation message of count
89 */
90 public void setCount(int count) {
91 this.count = count;
92 }
93
94 /**
95 * Return uuid.
96 * @return uuid
97 */
98 @JsonProperty("uuid")
99 public UUID getUuid() {
100 return uuid;
101 }
102
103 /**
104 * Set uuid value.
105 * @param uuid the Operation message of uuid
106 */
107 public void setUuid(String uuid) {
lishuai2f197432015-07-31 16:27:58 +0800108 checkNotNull(uuid, "uuid cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800109 this.uuid = UUID.uuid(uuid);
110 }
111
112 /**
113 * Return rows.
114 * @return List of Row
115 */
116 public List<Row> getRows() {
117 return rows;
118 }
119
120 /**
121 * Set rows value.
122 * @param rows the Operation message of rows
123 */
124 public void setRows(List<Row> rows) {
lishuai2f197432015-07-31 16:27:58 +0800125 checkNotNull(rows, "rows cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800126 this.rows = rows;
127 }
128
129 /**
130 * Return error.
131 * @return error
132 */
133 public String getError() {
134 return error;
135 }
136
137 /**
138 * Set error value.
139 * @param error the Operation message of error
140 */
141 public void setError(String error) {
lishuai2f197432015-07-31 16:27:58 +0800142 checkNotNull(error, "error cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800143 this.error = error;
144 }
145
146 /**
147 * Return details.
148 * @return details
149 */
150 public String getDetails() {
151 return details;
152 }
153
154 /**
155 * Set details value.
156 * @param details the Operation message of details
157 */
158 public void setDetails(String details) {
lishuai2f197432015-07-31 16:27:58 +0800159 checkNotNull(details, "details cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800160 this.details = details;
161 }
162}