blob: e6a0179ef47c4b1dfb9bbed014f82da18811b018 [file] [log] [blame]
Vidyashree Ramabd0903e2017-02-06 09:32:40 +05301/*
Brian O'Connor72b2df22017-08-03 18:48:28 -07002 * Copyright 2017-present Open Networking Foundation
Vidyashree Ramaf42405d2017-02-09 19:38:10 +05303 *
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.
Vidyashree Ramabd0903e2017-02-06 09:32:40 +053015 */
16
17package org.onosproject.yang.model;
18
Bharat saraswal45afe592017-03-19 23:34:32 +053019import java.util.Objects;
20
21import static com.google.common.base.MoreObjects.toStringHelper;
22import static java.util.Objects.hash;
23
Vidyashree Ramabd0903e2017-02-06 09:32:40 +053024/**
25 * Abstraction of an entity which identifies a generated class uniquely among
26 * its siblings.
27 */
28public class AtomicPath {
29
30 private DataNode.Type type;
31
32 /**
33 * Creates a atomic path object.
34 *
35 * @param type atomic path type
36 */
37 protected AtomicPath(DataNode.Type type) {
38 this.type = type;
39 }
40
41 /**
42 * Returns the atomic path type.
43 *
44 * @return the atomic path type
45 */
46 public DataNode.Type type() {
47 return type;
48 }
49
50 /**
51 * Sets the atomic path type identifier of leaf-list.
52 *
53 * @param type atomic path type
54 */
55 public void type(DataNode.Type type) {
56 this.type = type;
57 }
Bharat saraswal45afe592017-03-19 23:34:32 +053058
59 @Override
60 public int hashCode() {
61 return hash(type);
62 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (obj == null) {
67 return false;
68 }
69 AtomicPath that = (AtomicPath) obj;
70 return Objects.equals(type, that.type);
71 }
72
73 @Override
74 public String toString() {
75 return toStringHelper(getClass())
76 .add("type", type)
77 .toString();
78 }
Vidyashree Ramabd0903e2017-02-06 09:32:40 +053079}