Bharat saraswal | 59e7ac9 | 2017-01-19 19:51:50 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present 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 | |
| 17 | package org.onosproject.yang; |
| 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
| 25 | * Represents default YANG module identifier. |
| 26 | */ |
| 27 | public class DefaultYangModuleId implements YangModuleId { |
| 28 | |
| 29 | private String moduleName; |
| 30 | private String revision; |
| 31 | |
| 32 | /** |
| 33 | * Creates an instance of default YANG module id. |
| 34 | * |
| 35 | * @param name name of module |
| 36 | * @param rev revision of module |
| 37 | */ |
| 38 | public DefaultYangModuleId(String name, String rev) { |
| 39 | checkNotNull(name); |
Bharat saraswal | 59e7ac9 | 2017-01-19 19:51:50 +0530 | [diff] [blame] | 40 | moduleName = name; |
| 41 | revision = rev; |
| 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public String moduleName() { |
| 46 | return moduleName; |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public String revision() { |
| 51 | return revision; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public int hashCode() { |
| 56 | return Objects.hash(moduleName, revision); |
| 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public boolean equals(Object obj) { |
| 61 | if (obj == null) { |
| 62 | return false; |
| 63 | } |
| 64 | |
| 65 | DefaultYangModuleId that = (DefaultYangModuleId) obj; |
| 66 | return Objects.equals(moduleName, that.moduleName) && |
| 67 | Objects.equals(revision, that.revision); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public String toString() { |
| 72 | return toStringHelper(getClass()) |
| 73 | .add("moduleName", moduleName) |
| 74 | .add("revision", revision) |
| 75 | .toString(); |
| 76 | } |
| 77 | } |