blob: c3826fbb35a83b8e0bb645c701193b3e24e5dd3e [file] [log] [blame]
lishuai91d986c2015-07-28 09:45:20 +08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
lishuai91d986c2015-07-28 09:45:20 +08003 *
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;
Jonathan Hart51539b82015-10-29 09:53:04 -070023import org.onosproject.ovsdb.rfc.notation.Uuid;
lishuai91d986c2015-07-28 09:45:20 +080024
lishuai91d986c2015-07-28 09:45:20 +080025import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
lishuai91d986c2015-07-28 09:45:20 +080026
27/**
28 * All results of ovs table operations. refer to RFC7047 5.2.
29 */
30@JsonIgnoreProperties(ignoreUnknown = true)
31public final class OperationResult {
32 private int count;
Jonathan Hart51539b82015-10-29 09:53:04 -070033 private Uuid uuid;
lishuai91d986c2015-07-28 09:45:20 +080034 private List<Row> rows;
35 private String error;
36 private String details;
37
38 /**
39 * Constructs a OperationResult object. When JsonNode is converted into
40 * OperationResult, need this constructor and also need setter method.
41 */
42 public OperationResult() {
43 }
44
45 /**
46 * Constructs a OperationResult object.
47 * @param rows List of Row entity
48 */
49 public OperationResult(List<Row> rows) {
lishuai2f197432015-07-31 16:27:58 +080050 checkNotNull(rows, "rows cannot be null");
lishuai91d986c2015-07-28 09:45:20 +080051 this.rows = rows;
52 }
53
54 /**
55 * Constructs a OperationResult object.
56 * @param count the count node of result
57 * @param uuid UUID entity
58 * @param rows List of Row entity
59 * @param error error message
60 * @param details details of error message
61 */
Jonathan Hart51539b82015-10-29 09:53:04 -070062 public OperationResult(int count, Uuid uuid, List<Row> rows, String error,
lishuai91d986c2015-07-28 09:45:20 +080063 String details) {
lishuai2f197432015-07-31 16:27:58 +080064 checkNotNull(uuid, "uuid cannot be null");
65 checkNotNull(rows, "rows cannot be null");
66 checkNotNull(error, "error cannot be null");
67 checkNotNull(details, "details cannot be null");
lishuai91d986c2015-07-28 09:45:20 +080068 this.count = count;
69 this.uuid = uuid;
70 this.rows = rows;
71 this.error = error;
72 this.details = details;
73 }
74
75 /**
76 * Return count.
77 * @return count
78 */
79 public int getCount() {
80 return count;
81 }
82
83 /**
84 * Set count value.
85 * @param count the Operation message of count
86 */
87 public void setCount(int count) {
88 this.count = count;
89 }
90
91 /**
92 * Return uuid.
93 * @return uuid
94 */
Jonathan Hart51539b82015-10-29 09:53:04 -070095 public Uuid getUuid() {
lishuai91d986c2015-07-28 09:45:20 +080096 return uuid;
97 }
98
99 /**
100 * Set uuid value.
101 * @param uuid the Operation message of uuid
102 */
Jonathan Hart51539b82015-10-29 09:53:04 -0700103 public void setUuid(Uuid uuid) {
lishuai2f197432015-07-31 16:27:58 +0800104 checkNotNull(uuid, "uuid cannot be null");
lishuai35b34722015-08-05 14:34:25 +0800105 this.uuid = uuid;
lishuai91d986c2015-07-28 09:45:20 +0800106 }
107
108 /**
109 * Return rows.
110 * @return List of Row
111 */
112 public List<Row> getRows() {
113 return rows;
114 }
115
116 /**
117 * Set rows value.
118 * @param rows the Operation message of rows
119 */
120 public void setRows(List<Row> rows) {
lishuai2f197432015-07-31 16:27:58 +0800121 checkNotNull(rows, "rows cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800122 this.rows = rows;
123 }
124
125 /**
126 * Return error.
127 * @return error
128 */
129 public String getError() {
130 return error;
131 }
132
133 /**
134 * Set error value.
135 * @param error the Operation message of error
136 */
137 public void setError(String error) {
lishuai2f197432015-07-31 16:27:58 +0800138 checkNotNull(error, "error cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800139 this.error = error;
140 }
141
142 /**
143 * Return details.
144 * @return details
145 */
146 public String getDetails() {
147 return details;
148 }
149
150 /**
151 * Set details value.
152 * @param details the Operation message of details
153 */
154 public void setDetails(String details) {
lishuai2f197432015-07-31 16:27:58 +0800155 checkNotNull(details, "details cannot be null");
lishuai91d986c2015-07-28 09:45:20 +0800156 this.details = details;
157 }
158}