blob: 7ad0b217a3c93d75d90a287a8d61e435ceab8ceb [file] [log] [blame]
Andrea Campanella423962b2016-02-26 13:09:22 -08001/*
2 * Copyright 2016 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
17package org.onosproject.drivers.utilities;
18
19import com.google.common.base.MoreObjects;
20
21import java.util.Map;
22import java.util.Objects;
23
24/**
25 * Class that contains the element base key and a map with all the values to
26 * set or retrieved with their relative key.
27 */
28public class YangElement {
29
30 private final String baseKey;
31 private final Map<String, String> keysAndValues;
32
33 public YangElement(String baseKey, Map<String, String> keysAndValues) {
34 this.baseKey = baseKey;
35 this.keysAndValues = keysAndValues;
36 }
37
38 public Map<String, String> getKeysAndValues() {
39 return keysAndValues;
40 }
41
42 public String getBaseKey() {
43 return baseKey;
44 }
45
46
47 @Override
48 public String toString() {
49 return MoreObjects.toStringHelper(this)
50 .add("baseKey", baseKey)
51 .add("keysAndValues", keysAndValues)
52 .toString();
53 }
54
55 @Override
56 public boolean equals(Object o) {
57 if (this == o) {
58 return true;
59 }
60 if (o == null || getClass() != o.getClass()) {
61 return false;
62 }
63
64 YangElement element = (YangElement) o;
65
66 if (baseKey != null ? !baseKey.equals(element.baseKey) : element.baseKey != null) {
67 return false;
68 }
69 return (keysAndValues == null ? element.keysAndValues == null :
70 keysAndValues.equals(element.keysAndValues));
71
72 }
73
74 @Override
75 public int hashCode() {
76 return Objects.hash(baseKey, keysAndValues);
77 }
78}