1
2
3
4
5 package xjavadoc;
6
7 import org.apache.commons.collections.Predicate;
8
9 /***
10 * Describe what this class does
11 *
12 * @author Aslak Hellesøy
13 * @created 25. februar 2003
14 */
15 public interface XMethod extends XExecutableMember
16 {
17 /***
18 * Predicate that can be used to retrieve all property mutator methods.
19 */
20 public final static Predicate PROPERTY_MUTATOR_PREDICATE = new PropertyMutatorPredicate();
21
22 /***
23 * Predicate that can be used to retrieve all property accessor methods.
24 */
25 public final static Predicate PROPERTY_ACCESSOR_PREDICATE = new PropertyAccessorPredicate();
26
27 /***
28 * Returns the return type of the method.
29 *
30 * @return the return type of the method.
31 */
32 Type getReturnType();
33
34 /***
35 * Returns the type of the property this method represents, or null if this
36 * method is not a property method.
37 *
38 * @return the property type
39 * @see #isPropertyMutator
40 * @see #isPropertyAccessor
41 * @see #getPropertyName
42 */
43 Type getPropertyType();
44
45 /***
46 * Returns the property name of this method (if it is an accessor or mutator),
47 * or null if it is not.
48 *
49 * @return the property name.
50 */
51 String getPropertyName();
52
53 /***
54 * Returns the name of the method with the prefix stripped away. The prefix is
55 * the first series of lower case characters. Example:
56 * <ul>
57 * <li> "isIt" -> "It"</li>
58 * <li> "setIt" -> "It"</li>
59 * <li> "addIt" -> "It"</li>
60 * <li> "createIt" -> "It"</li>
61 * <li> "isit" -> null</li>
62 * </ul>
63 *
64 *
65 * @return the property name.
66 */
67 String getNameWithoutPrefix();
68
69 /***
70 * @return true if this is a public void setXxx(Xxx) method
71 */
72 boolean isPropertyMutator();
73
74 /***
75 * @return true if this is a public Xxx getXxx() method
76 */
77 boolean isPropertyAccessor();
78
79 /***
80 * If this method is a mutator, and a corresponding accessor exists, that
81 * accessor will be returned. Otherwise, null is returned.
82 *
83 * @return the corresponding accessor.
84 */
85 public XMethod getAccessor();
86
87 /***
88 * If this method is an accessor, and a corresponding mutator exists, that
89 * mutator will be returned. Otherwise, null is returned.
90 *
91 * @return the corresponding mutator.
92 */
93 public XMethod getMutator();
94
95 /***
96 * @created 20. mars 2003
97 */
98 static class PropertyAccessorPredicate implements Predicate
99 {
100 public boolean evaluate( Object o )
101 {
102 XMethod method = ( XMethod ) o;
103
104 return method.isPropertyAccessor();
105 }
106 }
107
108 /***
109 * @created 20. mars 2003
110 */
111 static class PropertyMutatorPredicate implements Predicate
112 {
113 public boolean evaluate( Object o )
114 {
115 XMethod method = ( XMethod ) o;
116
117 return method.isPropertyMutator();
118 }
119 }
120 }