本文整理了Java中java.lang.reflect.Executable.getDeclaringClass()
方法的一些代码示例,展示了Executable.getDeclaringClass()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Executable.getDeclaringClass()
方法的具体详情如下:
包路径:java.lang.reflect.Executable
类名称:Executable
方法名:getDeclaringClass
暂无
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the class that declares the underlying Method or Constructor.
*/
public Class<?> getDeclaringClass() {
return this.executable.getDeclaringClass();
}
代码示例来源:origin: org.springframework/spring-core
/**
* Return the class that declares the underlying Method or Constructor.
*/
public Class<?> getDeclaringClass() {
return this.executable.getDeclaringClass();
}
代码示例来源:origin: jdbi/jdbi
Class<?> getDeclaringClass() {
return executable.getDeclaringClass();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the generic type of the method/constructor parameter.
* @return the parameter type (never {@code null})
* @since 3.0
*/
public Type getGenericParameterType() {
Type paramType = this.genericParameterType;
if (paramType == null) {
if (this.parameterIndex < 0) {
Method method = getMethod();
paramType = (method != null ? method.getGenericReturnType() : void.class);
}
else {
Type[] genericParameterTypes = this.executable.getGenericParameterTypes();
int index = this.parameterIndex;
if (this.executable instanceof Constructor &&
ClassUtils.isInnerClass(this.executable.getDeclaringClass()) &&
genericParameterTypes.length == this.executable.getParameterCount() - 1) {
// Bug in javac: type array excludes enclosing instance parameter
// for inner classes with at least one generic constructor parameter,
// so access it with the actual parameter index lowered by 1
index = this.parameterIndex - 1;
}
paramType = (index >= 0 && index < genericParameterTypes.length ?
genericParameterTypes[index] : getParameterType());
}
this.genericParameterType = paramType;
}
return paramType;
}
代码示例来源:origin: AxonFramework/AxonFramework
private MethodCommandMessageHandlingMember(MessageHandlingMember<T> delegate,
Map<String, Object> annotationAttributes) {
super(delegate);
this.routingKey = "".equals(annotationAttributes.get("routingKey")) ? null :
(String) annotationAttributes.get("routingKey");
Executable executable = delegate.unwrap(Executable.class).orElseThrow(() -> new AxonConfigurationException(
"The @CommandHandler annotation must be put on an Executable (either directly or as Meta " +
"Annotation)"));
if ("".equals(annotationAttributes.get("commandName"))) {
commandName = delegate.payloadType().getName();
} else {
commandName = (String) annotationAttributes.get("commandName");
}
final boolean factoryMethod = executable instanceof Method && Modifier.isStatic(executable.getModifiers());
if (factoryMethod && !executable.getDeclaringClass().isAssignableFrom(((Method)executable).getReturnType())) {
throw new AxonConfigurationException("static @CommandHandler methods must declare a return value " +
"which is equal to or a subclass of the declaring time");
}
isFactoryHandler = executable instanceof Constructor || factoryMethod;
}
代码示例来源:origin: jooby-project/jooby
private Map<String, Object> md(final Executable exec) {
return Try.apply(() -> cache.getUnchecked(exec.getDeclaringClass()))
.unwrap(UncheckedExecutionException.class)
.get();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Return the annotations associated with the specific method/constructor parameter.
*/
public Annotation[] getParameterAnnotations() {
Annotation[] paramAnns = this.parameterAnnotations;
if (paramAnns == null) {
Annotation[][] annotationArray = this.executable.getParameterAnnotations();
int index = this.parameterIndex;
if (this.executable instanceof Constructor &&
ClassUtils.isInnerClass(this.executable.getDeclaringClass()) &&
annotationArray.length == this.executable.getParameterCount() - 1) {
// Bug in javac in JDK <9: annotation array excludes enclosing instance parameter
// for inner classes, so access it with the actual parameter index lowered by 1
index = this.parameterIndex - 1;
}
paramAnns = (index >= 0 && index < annotationArray.length ?
adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY);
this.parameterAnnotations = paramAnns;
}
return paramAnns;
}
代码示例来源:origin: org.springframework/spring-core
/**
* Return the generic type of the method/constructor parameter.
* @return the parameter type (never {@code null})
* @since 3.0
*/
public Type getGenericParameterType() {
Type paramType = this.genericParameterType;
if (paramType == null) {
if (this.parameterIndex < 0) {
Method method = getMethod();
paramType = (method != null ? method.getGenericReturnType() : void.class);
}
else {
Type[] genericParameterTypes = this.executable.getGenericParameterTypes();
int index = this.parameterIndex;
if (this.executable instanceof Constructor &&
ClassUtils.isInnerClass(this.executable.getDeclaringClass()) &&
genericParameterTypes.length == this.executable.getParameterCount() - 1) {
// Bug in javac: type array excludes enclosing instance parameter
// for inner classes with at least one generic constructor parameter,
// so access it with the actual parameter index lowered by 1
index = this.parameterIndex - 1;
}
paramType = (index >= 0 && index < genericParameterTypes.length ?
genericParameterTypes[index] : getParameterType());
}
this.genericParameterType = paramType;
}
return paramType;
}
代码示例来源:origin: spring-projects/spring-framework
if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) &&
executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
代码示例来源:origin: org.springframework/spring-core
/**
* Return the annotations associated with the specific method/constructor parameter.
*/
public Annotation[] getParameterAnnotations() {
Annotation[] paramAnns = this.parameterAnnotations;
if (paramAnns == null) {
Annotation[][] annotationArray = this.executable.getParameterAnnotations();
int index = this.parameterIndex;
if (this.executable instanceof Constructor &&
ClassUtils.isInnerClass(this.executable.getDeclaringClass()) &&
annotationArray.length == this.executable.getParameterCount() - 1) {
// Bug in javac in JDK <9: annotation array excludes enclosing instance parameter
// for inner classes, so access it with the actual parameter index lowered by 1
index = this.parameterIndex - 1;
}
paramAnns = (index >= 0 && index < annotationArray.length ?
adaptAnnotationArray(annotationArray[index]) : EMPTY_ANNOTATION_ARRAY);
this.parameterAnnotations = paramAnns;
}
return paramAnns;
}
代码示例来源:origin: oblac/jodd
/**
* Takes given parameters references and returns reference set for given method or constructor.
*/
public BeanReferences[] resolveReferenceFromValues(final Executable methodOrCtor, final String... parameterReferences) {
BeanReferences[] references = convertRefToReferences(parameterReferences);
if (references == null || references.length == 0) {
references = buildDefaultReferences(methodOrCtor);
}
if (methodOrCtor.getParameterTypes().length != references.length) {
throw new PetiteException("Different number of method parameters and references for: " +
methodOrCtor.getDeclaringClass().getName() + '#' + methodOrCtor.getName());
}
removeAllDuplicateNames(references);
return references;
}
代码示例来源:origin: spring-projects/spring-framework
Object argValue = argsToResolve[argIndex];
MethodParameter methodParam = MethodParameter.forExecutable(executable, argIndex);
GenericTypeResolver.resolveParameterType(methodParam, executable.getDeclaringClass());
if (argValue instanceof AutowiredArgumentMarker) {
argValue = resolveAutowiredArgument(methodParam, beanName, null, converter, fallback);
代码示例来源:origin: org.junit.jupiter/junit-jupiter-engine
Executable executable = getDeclaringExecutable();
if (executable instanceof Constructor && isInnerClass(executable.getDeclaringClass())
&& executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
代码示例来源:origin: org.springframework/spring-beans
Object argValue = argsToResolve[argIndex];
MethodParameter methodParam = MethodParameter.forExecutable(executable, argIndex);
GenericTypeResolver.resolveParameterType(methodParam, executable.getDeclaringClass());
if (argValue instanceof AutowiredArgumentMarker) {
argValue = resolveAutowiredArgument(methodParam, beanName, null, converter, fallback);
代码示例来源:origin: pholser/junit-quickcheck
private static String declarerName(Parameter p) {
Executable exec = p.getDeclaringExecutable();
return exec.getDeclaringClass().getName() + '.' + exec.getName();
}
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-core
/**
* Return the class that declares the underlying Method or Constructor.
*/
public Class<?> getDeclaringClass() {
return this.executable.getDeclaringClass();
}
代码示例来源:origin: com.pholser/junit-quickcheck-core
private static String declarerName(Parameter p) {
Executable exec = p.getDeclaringExecutable();
return exec.getDeclaringClass().getName() + '.' + exec.getName();
}
}
代码示例来源:origin: org.hibernate.validator/hibernate-validator
public ExecutableFormatter(Executable executable) {
String name = ExecutableHelper.getSimpleName( executable );
if ( executable instanceof Method ) {
name = executable.getDeclaringClass().getSimpleName() + "#" + name;
}
Class<?>[] parameterTypes = executable.getParameterTypes();
this.stringRepresentation = ExecutableHelper.getExecutableAsString( name, parameterTypes );
}
代码示例来源:origin: org.jooby/jooby
private Map<String, Object> md(final Executable exec) {
return Try.apply(() -> cache.getUnchecked(exec.getDeclaringClass()))
.unwrap(UncheckedExecutionException.class)
.get();
}
代码示例来源:origin: leangen/graphql-spqr
PropertyDescriptor fromConstructorParameter(AnnotatedParameter ctorParam) {
Executable constructor = (Executable) ctorParam.getOwner().getMember();
Parameter parameter = constructor.getParameters()[ctorParam.getIndex()];
AnnotatedType fieldType = transform(ClassUtils.getParameterTypes(constructor, type)[ctorParam.getIndex()], parameter);
return new PropertyDescriptor(type, constructor.getDeclaringClass(), parameter, fieldType, ctorParam);
}
内容来源于网络,如有侵权,请联系作者删除!