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.notation; |
| 17 | |
| 18 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 19 | import static com.google.common.base.Preconditions.checkNotNull; |
| 20 | |
| 21 | import java.util.Objects; |
| 22 | |
| 23 | import com.fasterxml.jackson.databind.JsonNode; |
| 24 | |
| 25 | /** |
| 26 | * The RefTable type that can be expanded to Row. Refer to RFC 7047 Section 3.2. |
| 27 | */ |
| 28 | public final class RefTableRow { |
| 29 | |
| 30 | private final String refTable; |
| 31 | private final JsonNode jsonNode; |
| 32 | |
| 33 | /** |
| 34 | * RefTableRow constructor. |
| 35 | * @param refTable the refTable value of JsonNode |
| 36 | * @param jsonNode JsonNode |
| 37 | */ |
| 38 | public RefTableRow(String refTable, JsonNode jsonNode) { |
lishuai | 2f19743 | 2015-07-31 16:27:58 +0800 | [diff] [blame] | 39 | checkNotNull(refTable, "refTable cannot be null"); |
| 40 | checkNotNull(jsonNode, "jsonNode cannot be null"); |
lishuai | 91d986c | 2015-07-28 09:45:20 +0800 | [diff] [blame] | 41 | this.refTable = refTable; |
| 42 | this.jsonNode = jsonNode; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Returns JsonNode. |
| 47 | * @return JsonNode |
| 48 | */ |
| 49 | public JsonNode jsonNode() { |
| 50 | return jsonNode; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns refTable. |
| 55 | * @return refTable |
| 56 | */ |
| 57 | public String refTable() { |
| 58 | return refTable; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public int hashCode() { |
| 63 | return Objects.hash(refTable, jsonNode); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public boolean equals(Object obj) { |
| 68 | if (this == obj) { |
| 69 | return true; |
| 70 | } |
| 71 | if (obj instanceof RefTableRow) { |
| 72 | final RefTableRow other = (RefTableRow) obj; |
| 73 | return Objects.equals(this.refTable, other.refTable) |
| 74 | && Objects.equals(this.jsonNode, other.jsonNode); |
| 75 | } |
| 76 | return false; |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public String toString() { |
| 81 | return toStringHelper(this).add("refTable", refTable) |
| 82 | .add("jsonNode", jsonNode).toString(); |
| 83 | } |
| 84 | } |