blob: 1b22a4262150e8877996496c9b6668bc2f951c3c [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.notation;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22
23import 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 */
28public 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) {
lishuai2f197432015-07-31 16:27:58 +080039 checkNotNull(refTable, "refTable cannot be null");
40 checkNotNull(jsonNode, "jsonNode cannot be null");
lishuai91d986c2015-07-28 09:45:20 +080041 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}