Package org.apache.juneau.reflect
Class ConstructorInfo
java.lang.Object
org.apache.juneau.reflect.ExecutableInfo
org.apache.juneau.reflect.ConstructorInfo
- All Implemented Interfaces:
Comparable<ConstructorInfo>
Lightweight utility class for introspecting information about a constructor.
See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
ConstructorInfo
(ClassInfo declaringClass, Constructor<?> c) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionaccept
(Predicate<ConstructorInfo> test, Consumer<ConstructorInfo> action) Performs an action on this object if the specified predicate test passes.Attempts to callx.setAccessible(
and quietly ignores security exceptions.true )Makes constructor accessible if it matches the visibility requirements, or returnsnull if it doesn't.boolean
Returnstrue if this constructor can accept the specified arguments in the specified order.int
<A extends Annotation>
AgetAnnotation
(Class<A> type) Finds the annotation of the specified type defined on this constructor.<A extends Annotation>
AgetAnnotation
(AnnotationProvider annotationProvider, Class<A> type) Finds the annotation of the specified type defined on this constructor.<A extends Annotation>
booleanhasAnnotation
(Class<A> type) Returnstrue if the specified annotation is present on this constructor.<A extends Annotation>
booleanhasAnnotation
(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is present on this constructor.<A extends Annotation>
booleanhasNoAnnotation
(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is not present on this constructor.<T> Constructor<T>
inner()
Returns the wrapped method.<T> T
Shortcut for calling the new-instance method on the underlying constructor.<T> T
invokeFuzzy
(Object... args) Shortcut for calling the new-instance method on the underlying constructor.boolean
matches
(Predicate<ConstructorInfo> test) Returnstrue if this object passes the specified predicate test.static ConstructorInfo
of
(Constructor<?> c) Convenience method for instantiating aConstructorInfo
;static ConstructorInfo
of
(ClassInfo declaringClass, Constructor<?> c) Convenience method for instantiating aConstructorInfo
;Methods inherited from class org.apache.juneau.reflect.ExecutableInfo
forEachParam, forEachParameterAnnotation, fuzzyArgsMatch, fuzzyArgsMatch, fuzzyArgsMatch, getDeclaringClass, getExceptionTypes, getFullName, getParam, getParamCount, getParams, getParamType, getParamTypes, getRawGenericParamType, getRawGenericParamTypes, getRawParameter, getRawParameters, getRawParamType, getRawParamTypes, getShortName, getSimpleName, hasFuzzyParamTypes, hasFuzzyParamTypes, hasMatchingParamTypes, hasMatchingParamTypes, hasName, hasName, hasName, hasNoParams, hasNumParams, hasParams, hasParamTypes, hasParamTypes, is, isAbstract, isAll, isAny, isConstructor, isDeprecated, isNotAbstract, isNotDeprecated, isNotProtected, isNotPublic, isNotStatic, isProtected, isPublic, isStatic, isVisible, setAccessible, toString
-
Constructor Details
-
ConstructorInfo
Constructor.- Parameters:
declaringClass
- The class that declares this method.c
- The constructor being wrapped.
-
-
Method Details
-
of
Convenience method for instantiating aConstructorInfo
;- Parameters:
declaringClass
- The class that declares this method.c
- The constructor being wrapped.- Returns:
- A new
ConstructorInfo
object, ornull if the method was null;
-
of
Convenience method for instantiating aConstructorInfo
;- Parameters:
c
- The constructor being wrapped.- Returns:
- A new
ConstructorInfo
object, ornull if the method was null;
-
inner
Returns the wrapped method.- Type Parameters:
T
- The inner class type.- Returns:
- The wrapped method.
-
getAnnotation
Finds the annotation of the specified type defined on this constructor.- Type Parameters:
A
- The annotation type to look for.- Parameters:
type
- The annotation to look for.- Returns:
- The annotation if found, or
null if not.
-
getAnnotation
Finds the annotation of the specified type defined on this constructor.- Type Parameters:
A
- The annotation type to look for.- Parameters:
annotationProvider
- The annotation provider.type
- The annotation to look for.- Returns:
- The first annotation found, or
null if it doesn't exist.
-
hasAnnotation
Returnstrue if the specified annotation is present on this constructor.- Type Parameters:
A
- The annotation type to look for.- Parameters:
type
- The annotation to look for.- Returns:
true if the specified annotation is present on this constructor.
-
hasAnnotation
public <A extends Annotation> boolean hasAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is present on this constructor.- Type Parameters:
A
- The annotation type to look for.- Parameters:
annotationProvider
- The annotation provider.type
- The annotation to look for.- Returns:
true if the specified annotation is present on this constructor.
-
hasNoAnnotation
public <A extends Annotation> boolean hasNoAnnotation(AnnotationProvider annotationProvider, Class<A> type) Returnstrue if the specified annotation is not present on this constructor.- Type Parameters:
A
- The annotation type to look for.- Parameters:
annotationProvider
- The annotation provider.type
- The annotation to look for.- Returns:
true if the specified annotation is not present on this constructor.
-
matches
Returnstrue if this object passes the specified predicate test.- Parameters:
test
- The test to perform.- Returns:
true if this object passes the specified predicate test.
-
accept
Performs an action on this object if the specified predicate test passes.- Parameters:
test
- A test to apply to determine if action should be executed. Can benull .action
- An action to perform on this object.- Returns:
- This object.
-
canAccept
Returnstrue if this constructor can accept the specified arguments in the specified order.- Parameters:
args
- The arguments to check.- Returns:
true if this constructor can accept the specified arguments in the specified order.
-
invokeFuzzy
Shortcut for calling the new-instance method on the underlying constructor.- Type Parameters:
T
- The constructor class type.- Parameters:
args
- the arguments used for the method call.
Extra parameters are ignored.
Missing parameters are set to null.- Returns:
- The object returned from the constructor.
- Throws:
ExecutableException
- Exception occurred on invoked constructor/method/field.
-
invoke
Shortcut for calling the new-instance method on the underlying constructor.- Type Parameters:
T
- The constructor class type.- Parameters:
args
- the arguments used for the method call.- Returns:
- The object returned from the constructor.
- Throws:
ExecutableException
- Exception occurred on invoked constructor/method/field.
-
accessible
Makes constructor accessible if it matches the visibility requirements, or returnsnull if it doesn't.Security exceptions thrown on the call to
Constructor.setAccessible(boolean)
are quietly ignored.- Parameters:
v
- The minimum visibility.- Returns:
- The same constructor if visibility requirements met, or
null if visibility requirement not met or call toConstructor.setAccessible(boolean)
throws a security exception.
-
compareTo
- Specified by:
compareTo
in interfaceComparable<ConstructorInfo>
-
accessible
Description copied from class:ExecutableInfo
Attempts to callx.setAccessible(
and quietly ignores security exceptions.true )- Overrides:
accessible
in classExecutableInfo
- Returns:
- This object.
-