|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MethodDescriptor.java | 100% | 100% | 100% | 100% |
|
1 |
/*
|
|
2 |
* Copyright (C) The MetaClass Group. All rights reserved.
|
|
3 |
*
|
|
4 |
* This software is published under the terms of the Spice
|
|
5 |
* Software License version 1.1, a copy of which has been included
|
|
6 |
* with this distribution in the LICENSE.txt file.
|
|
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 | 62 |
public MethodDescriptor( final String name,
|
50 |
final String returnType, |
|
51 |
final ParameterDescriptor[] parameters, |
|
52 |
final Attribute[] declaredAttributes, |
|
53 |
final Attribute[] attributes ) |
|
54 |
{ |
|
55 | 62 |
super( declaredAttributes, attributes );
|
56 | 62 |
if( null == name ) |
57 |
{ |
|
58 | 2 |
throw new NullPointerException( "name" ); |
59 |
} |
|
60 | 60 |
if( null == returnType ) |
61 |
{ |
|
62 | 2 |
throw new NullPointerException( "returnType" ); |
63 |
} |
|
64 | 58 |
if( null == parameters ) |
65 |
{ |
|
66 | 2 |
throw new NullPointerException( "parameters" ); |
67 |
} |
|
68 | 56 |
for( int i = 0; i < parameters.length; i++ ) |
69 |
{ |
|
70 | 14 |
if( null == parameters[ i ] ) |
71 |
{ |
|
72 | 2 |
throw new NullPointerException( "parameters[" + i + "]" ); |
73 |
} |
|
74 |
} |
|
75 |
|
|
76 | 54 |
m_name = name; |
77 | 54 |
m_returnType = returnType; |
78 | 54 |
m_parameters = parameters; |
79 |
} |
|
80 |
|
|
81 |
/**
|
|
82 |
* Return the name of the method.
|
|
83 |
*
|
|
84 |
* @return the name of the method.
|
|
85 |
*/
|
|
86 | 42 |
public String getName()
|
87 |
{ |
|
88 | 42 |
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 | 22 |
public String getReturnType()
|
97 |
{ |
|
98 | 22 |
return m_returnType;
|
99 |
} |
|
100 |
|
|
101 |
/**
|
|
102 |
* Return the parameters associated with method.
|
|
103 |
*
|
|
104 |
* @return the parameters associated with method.
|
|
105 |
*/
|
|
106 | 42 |
public ParameterDescriptor[] getParameters()
|
107 |
{ |
|
108 | 42 |
return m_parameters;
|
109 |
} |
|
110 |
} |
|
111 |
|
|