lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame^] | 2 | * Copyright 2015-present Open Networking Laboratory |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.ovsdb.rfc.message; |
| 17 | |
| 18 | import static com.google.common.base.Preconditions.checkNotNull; |
| 19 | |
| 20 | import java.util.List; |
| 21 | |
| 22 | import org.onosproject.ovsdb.rfc.notation.Row; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 23 | import org.onosproject.ovsdb.rfc.notation.Uuid; |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 24 | |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 25 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 26 | |
| 27 | /** |
| 28 | * All results of ovs table operations. refer to RFC7047 5.2. |
| 29 | */ |
| 30 | @JsonIgnoreProperties(ignoreUnknown = true) |
| 31 | public final class OperationResult { |
| 32 | private int count; |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 33 | private Uuid uuid; |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 34 | 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) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 50 | checkNotNull(rows, "rows cannot be null"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 51 | 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 Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 62 | public OperationResult(int count, Uuid uuid, List<Row> rows, String error, |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 63 | String details) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 64 | 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"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 68 | 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 Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 95 | public Uuid getUuid() { |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 96 | return uuid; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Set uuid value. |
| 101 | * @param uuid the Operation message of uuid |
| 102 | */ |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 103 | public void setUuid(Uuid uuid) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 104 | checkNotNull(uuid, "uuid cannot be null"); |
lishuai | 35b3472 | 2015-08-05 14:34:25 +0800 | [diff] [blame] | 105 | this.uuid = uuid; |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 106 | } |
| 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) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 121 | checkNotNull(rows, "rows cannot be null"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 122 | 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) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 138 | checkNotNull(error, "error cannot be null"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 139 | 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) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 155 | checkNotNull(details, "details cannot be null"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 156 | this.details = details; |
| 157 | } |
| 158 | } |