blob: 76d691df2197f745845942a8e51a0b8b7f641d7a [file] [log] [blame]
Bharat saraswal870c56f2016-02-20 21:57:16 +05301/*
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.yangutils.translator.tojava;
18
19import java.util.Objects;
20
21import com.google.common.base.MoreObjects;
22
23/**
24 * Maintains the information about individual imports in the generated file.
25 */
26public class ImportInfo {
27
28 /**
29 * Package location where the imported class/interface is defined.
30 */
31 private String pkgInfo;
32
33 /**
34 * class/interface being referenced.
35 */
36 private String classInfo;
37
38 /**
39 * Default constructor.
40 */
41 public ImportInfo() {
42 }
43
44 /**
45 * Get the imported package info.
46 *
47 * @return the imported package info.
48 */
49 public String getPkgInfo() {
50 return pkgInfo;
51 }
52
53 /**
54 * Set the imported package info.
55 *
56 * @param pkgInfo the imported package info.
57 */
58 public void setPkgInfo(String pkgInfo) {
59 this.pkgInfo = pkgInfo;
60 }
61
62 /**
63 * Get the imported class/interface info.
64 *
65 * @return the imported class/interface info.
66 */
67 public String getClassInfo() {
68 return classInfo;
69 }
70
71 /**
72 * Set the imported class/interface info.
73 *
74 * @param classInfo the imported class/interface info.
75 */
76 public void setClassInfo(String classInfo) {
77 this.classInfo = classInfo;
78 }
79
80 @Override
81 public int hashCode() {
82 return Objects.hash(pkgInfo, classInfo);
83 }
84
85 @Override
86 public boolean equals(Object obj) {
87 if (this == obj) {
88 return true;
89 }
90 if (obj instanceof ImportInfo) {
91 ImportInfo other = (ImportInfo) obj;
92 return Objects.equals(pkgInfo, other.pkgInfo) &&
93 Objects.equals(classInfo, other.classInfo);
94 }
95 return false;
96 }
97
98 /**
99 * check if the import info matches.
100 *
101 * @param importInfo matched import
102 * @return if equal or not
103 */
104 public boolean exactMatch(ImportInfo importInfo) {
105 return equals(importInfo)
106 && Objects.equals(pkgInfo, importInfo.getPkgInfo())
107 && Objects.equals(classInfo, importInfo.getClassInfo());
108 }
109
110 @Override
111 public String toString() {
112 return MoreObjects.toStringHelper(getClass())
113 .add("pkgInfo", pkgInfo)
114 .add("classInfo", classInfo).toString();
115 }
116
117}