1 package com.fasterxml.classmate.members;
2
3 import java.lang.reflect.Method;
4 import java.lang.reflect.Modifier;
5
6 import com.fasterxml.classmate.Annotations;
7 import com.fasterxml.classmate.ResolvedType;
8
9 public final class ResolvedMethod extends ResolvedParameterizedMember<Method>
10      implements Comparable<ResolvedMethod>
11 {
12     public ResolvedMethod(ResolvedType context, Annotations ann, Method method,
13             ResolvedType returnType, ResolvedType[] argumentTypes)
14     {
15         super(context, ann, method, returnType, argumentTypes);
16     }
17
18     /*
19     /**********************************************************************
20     /* Simple accessors from base class
21     /**********************************************************************
22      */

23
24     public boolean isAbstract() {
25         return Modifier.isAbstract(getModifiers());
26     }
27
28     public boolean isStrict() {
29         return Modifier.isStrict(getModifiers());
30     }
31
32     public boolean isNative() {
33         return Modifier.isNative(getModifiers());
34     }
35
36     public boolean isSynchronized() {
37         return Modifier.isSynchronized(getModifiers());
38     }
39
40     /*
41     /**********************************************************************
42     /* Extended API
43     /**********************************************************************
44      */

45
46     public ResolvedType getReturnType() { return getType(); }
47
48     /*
49     /**********************************************************************
50     /* Standard method override
51     /**********************************************************************
52      */

53
54     @Override
55     public int compareTo(ResolvedMethod other)
56     {
57          // primary sort by name (alphabetic); secondary by arg count (ascending)
58          int diff = getName().compareTo(other.getName());
59          if (diff == 0) {
60               // subtract fine, no fear of overflow here
61               diff = getArgumentCount() - other.getArgumentCount();
62          }
63          return diff;
64     }
65 }
66