Vidyashree Rama | bd0903e | 2017-02-06 09:32:40 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 72b2df2 | 2017-08-03 18:48:28 -0700 | [diff] [blame] | 2 | * Copyright 2017-present Open Networking Foundation |
Vidyashree Rama | f42405d | 2017-02-09 19:38:10 +0530 | [diff] [blame] | 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. |
Vidyashree Rama | bd0903e | 2017-02-06 09:32:40 +0530 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | package org.onosproject.yang.model; |
| 18 | |
Bharat saraswal | 45afe59 | 2017-03-19 23:34:32 +0530 | [diff] [blame] | 19 | import java.util.Objects; |
| 20 | |
| 21 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 22 | import static java.util.Objects.hash; |
| 23 | |
Vidyashree Rama | bd0903e | 2017-02-06 09:32:40 +0530 | [diff] [blame] | 24 | /** |
| 25 | * Abstraction of an entity which identifies a generated class uniquely among |
| 26 | * its siblings. |
| 27 | */ |
| 28 | public 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 saraswal | 45afe59 | 2017-03-19 23:34:32 +0530 | [diff] [blame] | 58 | |
| 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 Rama | bd0903e | 2017-02-06 09:32:40 +0530 | [diff] [blame] | 79 | } |