78 public boolean equals(Object obj) { 79 if(obj instanceof Parameter) { 80 Parameter other = (Parameter)obj; 81 return (other.executable.equals(executable) && 82 other.index == index); 83 } 84 return false; 85 } 86 87 /** 88 * Returns a hash code based on the executable's hash code and the 89 * index. 90 * 91 * @return A hash code based on the executable's hash code. 92 */ 93 public int hashCode() { 94 return executable.hashCode() ^ index; 95 } 96 97 /** 98 * Returns a string describing this parameter. The format is the 99 * modifiers for the parameter, if any, in canonical order as 100 * recommended by <cite>The Java™ Language 101 * Specification</cite>, followed by the fully- qualified type of 102 * the parameter (excluding the last [] if the parameter is 103 * variable arity), followed by "..." if the parameter is variable 104 * arity, followed by a space, followed by the name of the 105 * parameter. 106 * 107 * @return A string representation of the parameter and associated 108 * information. 109 */ 110 public String toString() { 111 final StringBuilder sb = new StringBuilder(); 112 final Type type = getParameterizedType(); 113 final String typename = type.getTypeName(); 114 115 sb.append(Modifier.toString(getModifiers())); 116 117 if(0 != modifiers) 132 * Return the {@code Executable} which declares this parameter. 133 * 134 * @return The {@code Executable} declaring this parameter. 135 */ 136 public Executable getDeclaringExecutable() { 137 return executable; 138 } 139 140 /** 141 * Get the modifier flags for this the parameter represented by 142 * this {@code Parameter} object. 143 * 144 * @return The modifier flags for this parameter. 145 */ 146 public int getModifiers() { 147 return modifiers; 148 } 149 150 /** 151 * Returns the name of the parameter. If the parameter's name is 152 * defined in a class file, then that name will be returned by 153 * this method. Otherwise, this method will synthesize a name of 154 * the form argN, where N is the index of the parameter. 155 */ 156 public String getName() { 157 // Note: empty strings as paramete names are now outlawed. 158 // The .equals("") is for compatibility with current JVM 159 // behavior. It may be removed at some point. 160 if(name == null || name.equals("")) 161 return "arg" + index; 162 else 163 return name; 164 } 165 166 /** 167 * Returns a {@code Type} object that identifies the parameterized 168 * type for the parameter represented by this {@code Parameter} 169 * object. 170 * 171 * @return a {@code Type} object identifying the parameterized 172 * type of the parameter represented by this object 173 */ 174 public Type getParameterizedType() { | 78 public boolean equals(Object obj) { 79 if(obj instanceof Parameter) { 80 Parameter other = (Parameter)obj; 81 return (other.executable.equals(executable) && 82 other.index == index); 83 } 84 return false; 85 } 86 87 /** 88 * Returns a hash code based on the executable's hash code and the 89 * index. 90 * 91 * @return A hash code based on the executable's hash code. 92 */ 93 public int hashCode() { 94 return executable.hashCode() ^ index; 95 } 96 97 /** 98 * Returns true if the parameter has a name according to the class 99 * file; returns false otherwise. Whether a parameter has a name 100 * is determined by the {@literal MethodParameters} attribute of 101 * the method which declares the parameter. 102 * 103 * @return true if and only if the parameter has a name according 104 * to the class file. 105 */ 106 public boolean isNamePresent() { 107 return executable.hasRealParameterData(); 108 } 109 110 /** 111 * Returns a string describing this parameter. The format is the 112 * modifiers for the parameter, if any, in canonical order as 113 * recommended by <cite>The Java™ Language 114 * Specification</cite>, followed by the fully- qualified type of 115 * the parameter (excluding the last [] if the parameter is 116 * variable arity), followed by "..." if the parameter is variable 117 * arity, followed by a space, followed by the name of the 118 * parameter. 119 * 120 * @return A string representation of the parameter and associated 121 * information. 122 */ 123 public String toString() { 124 final StringBuilder sb = new StringBuilder(); 125 final Type type = getParameterizedType(); 126 final String typename = type.getTypeName(); 127 128 sb.append(Modifier.toString(getModifiers())); 129 130 if(0 != modifiers) 145 * Return the {@code Executable} which declares this parameter. 146 * 147 * @return The {@code Executable} declaring this parameter. 148 */ 149 public Executable getDeclaringExecutable() { 150 return executable; 151 } 152 153 /** 154 * Get the modifier flags for this the parameter represented by 155 * this {@code Parameter} object. 156 * 157 * @return The modifier flags for this parameter. 158 */ 159 public int getModifiers() { 160 return modifiers; 161 } 162 163 /** 164 * Returns the name of the parameter. If the parameter's name is 165 * {@linkplain isNamePresent() present}, then this method returns 166 * the name provided by the class file. Otherwise, this method 167 * synthesizes a name of the form argN, where N is the index of 168 * the parameter in the descriptor of the method which declares 169 * the parameter. 170 * 171 * @return The name of the parameter, either provided by the class 172 * file or synthesized if the class file does not provide 173 * a name. 174 */ 175 public String getName() { 176 // Note: empty strings as paramete names are now outlawed. 177 // The .equals("") is for compatibility with current JVM 178 // behavior. It may be removed at some point. 179 if(name == null || name.equals("")) 180 return "arg" + index; 181 else 182 return name; 183 } 184 185 /** 186 * Returns a {@code Type} object that identifies the parameterized 187 * type for the parameter represented by this {@code Parameter} 188 * object. 189 * 190 * @return a {@code Type} object identifying the parameterized 191 * type of the parameter represented by this object 192 */ 193 public Type getParameterizedType() { |