View Javadoc

1   /**
2    * BSD-style license; for more info see http://pmd.sourceforge.net/license.html
3    */
4   package net.sourceforge.pmd.lang.java.rule;
5   
6   import net.sourceforge.pmd.lang.ast.Node;
7   
8   public class ImportWrapper {
9       private Node node;
10      private String name;
11      private String fullname;
12  
13      public ImportWrapper(String fullname, String name, Node node) {
14          this.fullname = fullname;
15          this.name = name;
16          this.node = node;
17      }
18  
19      public boolean equals(Object other) {
20      	if (other == null) return false;
21      	if (other == this) return true;
22      	if (other instanceof ImportWrapper) {
23  	        ImportWrapper i = (ImportWrapper) other;
24  	        if(name == null && i.getName() == null){
25  	            return i.getFullName().equals(fullname);
26  	        }
27  	        return i.getName().equals(name);
28      	}
29      	return false;
30      }
31  
32      public int hashCode() {
33          if(name == null){
34              return fullname.hashCode();
35          }
36          return name.hashCode();
37      }
38  
39      public String getName() {
40          return name;
41      }
42  
43      public String getFullName() {
44          return fullname;
45      }
46  
47      public Node getNode() {
48          return node;
49      }
50  }
51