1 package com.fasterxml.classmate.members;
2
3 import java.lang.reflect.Constructor;
4
5 import com.fasterxml.classmate.ResolvedType;
6 import com.fasterxml.classmate.util.MethodKey;
7
8 public final class RawConstructor extends RawMember
9 {
10     protected final Constructor<?> _constructor;
11
12     protected final int _hashCode;
13
14     public RawConstructor(ResolvedType context, Constructor<?> constructor)
15     {
16         super(context);
17         _constructor = constructor;
18         _hashCode = (_constructor == null ? 0 : _constructor.hashCode());
19     }
20
21     /**
22      * Although constructors are different from other methods, we can use
23      * {@link MethodKey} easily.
24      */

25     public MethodKey createKey()
26     {
27         String name = "<init>"// do not use _constructor.getName() to allow for 'mix-ins'
28         Class<?>[] argTypes = _constructor.getParameterTypes();  // return of Constructor#getParameterTypes will never be null
29         return new MethodKey(name, argTypes);
30     }
31     
32     /*
33     /**********************************************************************
34     /* Simple accessors
35     /**********************************************************************
36      */

37
38     @Override
39     public Constructor<?> getRawMember() {
40         return _constructor;
41     }
42     
43     /*
44     /**********************************************************************
45     /* Standard methods
46     /**********************************************************************
47      */

48
49     @Override public int hashCode()
50     {
51         return _hashCode;
52     }
53
54     @Override public boolean equals(Object o)
55     {
56         if (o == thisreturn true;
57         if (o == null || o.getClass() != getClass()) return false;
58         RawConstructor other = (RawConstructor) o;
59         return (other._constructor == _constructor);
60     }
61 }
62