/** * Return the class that declares the underlying Method or Constructor. */ public Class<?> getDeclaringClass() { return this.executable.getDeclaringClass(); }
/** * Return the class that declares the underlying Method or Constructor. */ public Class<?> getDeclaringClass() { return this.executable.getDeclaringClass(); }
Class<?> getDeclaringClass() { return executable.getDeclaringClass(); }
/** * 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; }
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; }
private Map<String, Object> md(final Executable exec) { return Try.apply(() -> cache.getUnchecked(exec.getDeclaringClass())) .unwrap(UncheckedExecutionException.class) .get(); }
/** * 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; }
/** * 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; }
if (executable instanceof Constructor && ClassUtils.isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
/** * 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; }
/** * 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; }
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);
Executable executable = getDeclaringExecutable(); if (executable instanceof Constructor && isInnerClass(executable.getDeclaringClass()) && executable.getParameterAnnotations().length == executable.getParameterCount() - 1) {
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);
private static String declarerName(Parameter p) { Executable exec = p.getDeclaringExecutable(); return exec.getDeclaringClass().getName() + '.' + exec.getName(); } }
/** * Return the class that declares the underlying Method or Constructor. */ public Class<?> getDeclaringClass() { return this.executable.getDeclaringClass(); }
private static String declarerName(Parameter p) { Executable exec = p.getDeclaringExecutable(); return exec.getDeclaringClass().getName() + '.' + exec.getName(); } }
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 ); }
private Map<String, Object> md(final Executable exec) { return Try.apply(() -> cache.getUnchecked(exec.getDeclaringClass())) .unwrap(UncheckedExecutionException.class) .get(); }
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); }