1
2
3
4
5
6
7
8 package org.codehaus.metaclass.model;
9
10 import java.io.Serializable;
11
12 /***
13 * A descriptor that describes a Method. It contains information about; <ul>
14 * <li>name: the name of the method</li> <li>return type: the return type of the
15 * method</li> <li>modifiers: the access modifiers for the method</li>
16 * <li>parameters: the parameters a method takes</li> </ul>
17 *
18 * <p>Also associated with each method is a set of arbitrary Attributes that can
19 * be used to store extra information about method.</p>
20 *
21 * @author Peter Donald
22 * @version $Revision: 1.11 $ $Date: 2003/12/11 08:41:50 $
23 */
24 public final class MethodDescriptor
25 extends FeatureDescriptor
26 implements Serializable
27 {
28 /*** Constant for empty array of method descriptors. */
29 public static final MethodDescriptor[] EMPTY_SET = new MethodDescriptor[ 0 ];
30
31 /*** The name of the Method. */
32 private final String m_name;
33
34 /*** The return type of the method. */
35 private final String m_returnType;
36
37 /*** The parameters associated with the method. */
38 private final ParameterDescriptor[] m_parameters;
39
40 /***
41 * Create a descriptor for a method.
42 *
43 * @param name the name of the method
44 * @param returnType the return type of the method
45 * @param parameters the parameters of the method
46 * @param declaredAttributes the declared attributes
47 * @param attributes any attributes associated with method
48 */
49 public MethodDescriptor( final String name,
50 final String returnType,
51 final ParameterDescriptor[] parameters,
52 final Attribute[] declaredAttributes,
53 final Attribute[] attributes )
54 {
55 super( declaredAttributes, attributes );
56 if( null == name )
57 {
58 throw new NullPointerException( "name" );
59 }
60 if( null == returnType )
61 {
62 throw new NullPointerException( "returnType" );
63 }
64 if( null == parameters )
65 {
66 throw new NullPointerException( "parameters" );
67 }
68 for( int i = 0; i < parameters.length; i++ )
69 {
70 if( null == parameters[ i ] )
71 {
72 throw new NullPointerException( "parameters[" + i + "]" );
73 }
74 }
75
76 m_name = name;
77 m_returnType = returnType;
78 m_parameters = parameters;
79 }
80
81 /***
82 * Return the name of the method.
83 *
84 * @return the name of the method.
85 */
86 public String getName()
87 {
88 return m_name;
89 }
90
91 /***
92 * Return the return type of the method.
93 *
94 * @return the return type of the method.
95 */
96 public String getReturnType()
97 {
98 return m_returnType;
99 }
100
101 /***
102 * Return the parameters associated with method.
103 *
104 * @return the parameters associated with method.
105 */
106 public ParameterDescriptor[] getParameters()
107 {
108 return m_parameters;
109 }
110 }