1 19 20 package edu.umd.cs.findbugs.classfile; 21 22 27 public abstract class FieldOrMethodDescriptor { 28 private String className; 29 private String name; 30 private String signature; 31 private boolean isStatic; 32 33 public FieldOrMethodDescriptor(String className, String name, String signature, boolean isStatic) { 34 this.className = className; 35 this.name = name; 36 this.signature = signature; 37 this.isStatic = isStatic; 38 } 39 40 43 public String getClassName() { 44 return className; 45 } 46 47 50 public String getName() { 51 return name; 52 } 53 54 57 public String getSignature() { 58 return signature; 59 } 60 61 64 public boolean isStatic() { 65 return isStatic; 66 } 67 68 protected int compareTo(FieldOrMethodDescriptor o) { 69 int cmp; 70 cmp = this.className.compareTo(o.className); 71 if (cmp != 0) { 72 return cmp; 73 } 74 cmp = this.name.compareTo(o.name); 75 if (cmp != 0) { 76 return cmp; 77 } 78 cmp = this.signature.compareTo(o.signature); 79 if (cmp != 0) { 80 return cmp; 81 } 82 return (this.isStatic ? 1 : 0) - (o.isStatic ? 1 : 0); 83 } 84 85 88 @Override 89 public boolean equals(Object obj) { 90 if (obj == null || obj.getClass() != this.getClass()) { 91 return false; 92 } 93 FieldOrMethodDescriptor other = (FieldOrMethodDescriptor) obj; 94 return this.className.equals(other.className) 95 && this.name.equals(other.name) 96 && this.signature.equals(other.signature) 97 && this.isStatic == other.isStatic; 98 } 99 100 103 @Override 104 public int hashCode() { 105 return className.hashCode() * 7919 106 + name.hashCode() * 3119 107 + signature.hashCode() * 131 108 + (isStatic ? 1 : 0); 109 } 110 111 114 @Override 115 public String toString() { 116 return (isStatic ? "static " : "") + className + "." + name + ":" + signature; 118 } 119 } 120 | Popular Tags |