lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 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; |
| 23 | import org.onosproject.ovsdb.rfc.notation.UUID; |
| 24 | |
| 25 | import com.fasterxml.jackson.annotation.JsonIgnore; |
| 26 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
| 27 | import com.fasterxml.jackson.annotation.JsonProperty; |
| 28 | |
| 29 | /** |
| 30 | * All results of ovs table operations. refer to RFC7047 5.2. |
| 31 | */ |
| 32 | @JsonIgnoreProperties(ignoreUnknown = true) |
| 33 | public 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) { |
| 53 | checkNotNull(rows, "rows is not null"); |
| 54 | 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) { |
| 67 | checkNotNull(uuid, "uuid is not null"); |
| 68 | checkNotNull(rows, "rows is not null"); |
| 69 | checkNotNull(error, "error is not null"); |
| 70 | checkNotNull(details, "details is not null"); |
| 71 | 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) { |
| 108 | checkNotNull(uuid, "uuid is not null"); |
| 109 | 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) { |
| 125 | checkNotNull(rows, "rows is not null"); |
| 126 | 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) { |
| 142 | checkNotNull(error, "error is not null"); |
| 143 | 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) { |
| 159 | checkNotNull(details, "details is not null"); |
| 160 | this.details = details; |
| 161 | } |
| 162 | } |