1 package org.codehaus.mojo.jaxb2.schemageneration.postprocessing.javadoc.location;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import com.thoughtworks.qdox.model.JavaParameter;
23 import org.codehaus.mojo.jaxb2.shared.Validate;
24
25 import java.util.List;
26
27
28
29
30
31
32
33 public class MethodLocation extends FieldLocation {
34
35
36
37
38 public static final String NO_PARAMETERS = "()";
39
40
41
42
43 public static final String PARAMETER_SEPARATOR = ",";
44
45
46 private String parameters = NO_PARAMETERS;
47
48 public MethodLocation(final String packageName,
49 final String className,
50 final String memberName,
51 final List<JavaParameter> parameters) {
52
53 super(packageName, className, memberName);
54
55
56 Validate.notNull(parameters, "parameters");
57
58
59 if (parameters.size() > 0) {
60 final StringBuilder builder = new StringBuilder();
61
62 for (JavaParameter current : parameters) {
63 builder.append(current.getType().getFullyQualifiedName()).append(PARAMETER_SEPARATOR);
64 }
65 this.parameters = "(" + builder.substring(0, builder.lastIndexOf(PARAMETER_SEPARATOR)) + ")";
66 }
67 }
68
69
70
71
72 @Override
73 public String toString() {
74 return super.toString() + parameters;
75 }
76
77
78
79
80 @Override
81 public int hashCode() {
82 return this.toString().hashCode();
83 }
84
85
86
87
88 public String getParametersAsString() {
89 return parameters;
90 }
91
92
93
94
95 public boolean hasNoParameters() {
96 return NO_PARAMETERS.equals(parameters);
97 }
98 }