T - the class that declares this constructorpublic final class Constructor<T> extends AbstractMethod implements GenericDeclaration, Member
accessFlags, artMethod, declaringClass, declaringClassOfOverriddenMethod, dexMethodIndex| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other)
Returns true if
other has the same declaring class and parameters
as this constructor. |
<A extends Annotation> |
getAnnotation(Class<A> annotationType)
Returns, for this element, the annotation with the specified type, or
null if no annotation with the specified type is present
(including inherited annotations). |
Annotation[] |
getAnnotations()
Returns, for this element, an array containing all annotations (including
inherited annotations).
|
Annotation[] |
getDeclaredAnnotations()
Returns, for this element, all annotations that are explicitly declared
(not inherited).
|
Class<T> |
getDeclaringClass()
Returns the class that declares this constructor.
|
Class<?>[] |
getExceptionTypes()
Returns the exception types as an array of
Class instances. |
Type[] |
getGenericExceptionTypes()
Returns the exception types as an array of
Type instances. |
Type[] |
getGenericParameterTypes()
Returns the generic parameter types as an array of
Type
instances, in declaration order. |
int |
getModifiers()
Returns the modifiers for this constructor.
|
String |
getName()
Returns the name of this constructor.
|
Annotation[][] |
getParameterAnnotations()
Returns an array of arrays that represent the annotations of the formal
parameters of this constructor.
|
Class<?>[] |
getParameterTypes()
Returns an array of the
Class objects associated with the
parameter types of this constructor. |
TypeVariable<Constructor<T>>[] |
getTypeParameters()
Returns the declared type parameters in declaration order.
|
int |
hashCode()
Returns an integer hash code for this object.
|
boolean |
isAnnotationPresent(Class<? extends Annotation> annotationType)
Indicates whether or not this element has an annotation with the
specified annotation type (including inherited annotations).
|
boolean |
isSynthetic()
Returns true if this constructor is synthetic (artificially introduced by the compiler).
|
boolean |
isVarArgs()
Returns true if this constructor takes a variable number of arguments.
|
T |
newInstance(Object... args)
Returns a new instance of the declaring class, initialized by dynamically
invoking the constructor represented by this
Constructor object. |
void |
setAccessible(boolean flag)
Attempts to set the accessible flag.
|
String |
toGenericString()
Returns the string representation of the constructor's declaration,
including the type parameters.
|
String |
toString()
Returns a string containing a concise, human-readable description of this
constructor.
|
compareParameters, equalMethodParameters, getAccessFlags, getDexMethodIndexisAccessible, setAccessiblepublic Annotation[] getAnnotations()
AnnotatedElementgetAnnotations in interface AnnotatedElementgetAnnotations in class AbstractMethodpublic int getModifiers()
Modifier class
should be used to decode the result.getModifiers in interface MemberModifierpublic boolean isVarArgs()
public boolean isSynthetic()
isSynthetic in interface Membertrue if this member is synthetic, false otherwisepublic String getName()
getName in interface MembergetName in class AbstractMethodpublic Class<T> getDeclaringClass()
getDeclaringClass in interface Memberpublic Class<?>[] getExceptionTypes()
Class instances. If
this constructor has no declared exceptions, an empty array will be
returned.public Class<?>[] getParameterTypes()
Class objects associated with the
parameter types of this constructor. If the constructor was declared with
no parameters, an empty array will be returned.public int hashCode()
Object.equals(java.lang.Object) returns true must return
the same hash code value. This means that subclasses of Object
usually override both methods or neither method.
Note that hash values must not change over time unless information used in equals comparisons also changes.
See Writing a correct
hashCode method
if you intend implementing your own hashCode method.
Equivalent to getDeclaringClass().getName().hashCode().
hashCode in class ObjectObject.equals(java.lang.Object)public boolean equals(Object other)
other has the same declaring class and parameters
as this constructor.equals in class AbstractMethodother - the object to compare this instance with.true if the specified object is equal to this Object; false otherwise.Object.hashCode()public TypeVariable<Constructor<T>>[] getTypeParameters()
GenericDeclarationgetTypeParameters in interface GenericDeclarationpublic String toGenericString()
public Type[] getGenericParameterTypes()
Type
instances, in declaration order. If this constructor has no generic
parameters, an empty array is returned.GenericSignatureFormatError - if the generic constructor signature is invalidTypeNotPresentException - if any parameter type points to a missing typeMalformedParameterizedTypeException - if any parameter type points to a type that cannot be
instantiated for some reasonpublic Type[] getGenericExceptionTypes()
Type instances. If
this constructor has no declared exceptions, an empty array will be
returned.GenericSignatureFormatError - if the generic constructor signature is invalidTypeNotPresentException - if any exception type points to a missing typeMalformedParameterizedTypeException - if any exception type points to a type that cannot be
instantiated for some reasonpublic Annotation[] getDeclaredAnnotations()
AnnotatedElementgetDeclaredAnnotations in interface AnnotatedElementgetDeclaredAnnotations in class AbstractMethodpublic boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
AnnotatedElementisAnnotationPresent in interface AnnotatedElementisAnnotationPresent in class AbstractMethodannotationType - the type of the annotation to search fortrue if the annotation exists, false otherwisepublic <A extends Annotation> A getAnnotation(Class<A> annotationType)
AnnotatedElementnull if no annotation with the specified type is present
(including inherited annotations).getAnnotation in interface AnnotatedElementgetAnnotation in class AbstractMethodannotationType - the type of the annotation to search fornullpublic Annotation[][] getParameterAnnotations()
getParameterAnnotations in class AbstractMethodAnnotation instancespublic T newInstance(Object... args) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
Constructor object.
This reproduces the effect of new declaringClass(arg1, arg2, ... ,
argN) This method performs the following:
AccessibleObject) and this constructor is not accessible from the
current context, an IllegalAccessException is thrown.Constructor object is
then invoked. If an exception is thrown during the invocation, it is
caught and wrapped in an InvocationTargetException. This exception is
then thrown. If the invocation completes normally, the newly initialized
object is returned.
args - the arguments to the constructorInstantiationException - if the class cannot be instantiatedIllegalAccessException - if this constructor is not accessibleIllegalArgumentException - if an incorrect number of arguments are passed, or an
argument could not be converted by a widening conversionInvocationTargetException - if an exception was thrown by the invoked constructorAccessibleObjectpublic String toString()
public String(byte[],String) throws UnsupportedEncodingExceptionpublic void setAccessible(boolean flag)
IllegalAccessExceptions.setAccessible in class AccessibleObject