Skip to content

Commit

Permalink
extract private method (#10473)
Browse files Browse the repository at this point in the history
  • Loading branch information
sdelamo authored Feb 9, 2024
1 parent da03790 commit 889ed07
Showing 1 changed file with 27 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -347,25 +347,9 @@ private DispatchedExecutableMethod(AbstractExecutableMethodsDefinition dispatche
this.index = index;
this.methodReference = methodReference;
this.annotationMetadata = annotationMetadata;
this.arguments = new Argument[methodReference.arguments.length];
boolean foundExpressions = false;
Argument<?>[] methodArguments = methodReference.arguments;
for (int i = 0; i < methodArguments.length; i++) {
Argument<?> argument = methodArguments[i];
AnnotationMetadata argumentAnnotationMetadata = argument.getAnnotationMetadata();
AnnotationMetadata wrappedArgumentAnnotationMetadata = EvaluatedAnnotationMetadata.wrapIfNecessary(argumentAnnotationMetadata);
if (argumentAnnotationMetadata == wrappedArgumentAnnotationMetadata) {
arguments[i] = argument;
} else {
foundExpressions = true;
if (argument instanceof GenericPlaceholder<?> genericPlaceholder) {
arguments[i] = Argument.ofTypeVariable(argument.getType(), argument.getName(), genericPlaceholder.getVariableName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
} else {
arguments[i] = Argument.of(argument.getType(), argument.getName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
}
}
}
this.argumentsAnnotationsWithExpressions = foundExpressions;
MethodArguments methodArguments = methodArguments(methodReference);
this.arguments = methodArguments.arguments;
this.argumentsAnnotationsWithExpressions = methodArguments.argumentsAnnotationsWithExpressions;
}

@Override
Expand Down Expand Up @@ -505,6 +489,30 @@ public String toString() {
return getReturnType().getType().getSimpleName() + " " + getMethodName() + "(" + text + ")";
}

private record MethodArguments(Argument<?>[] arguments, boolean argumentsAnnotationsWithExpressions) {
}

private MethodArguments methodArguments(MethodReference methodReference) {
final Argument<?>[] arguments= new Argument[methodReference.arguments.length];
boolean foundExpressions = false;
Argument<?>[] methodArguments = methodReference.arguments;
for (int i = 0; i < methodArguments.length; i++) {
Argument<?> argument = methodArguments[i];
AnnotationMetadata argumentAnnotationMetadata = argument.getAnnotationMetadata();
AnnotationMetadata wrappedArgumentAnnotationMetadata = EvaluatedAnnotationMetadata.wrapIfNecessary(argumentAnnotationMetadata);
if (argumentAnnotationMetadata == wrappedArgumentAnnotationMetadata) {
arguments[i] = argument;
} else {
foundExpressions = true;
if (argument instanceof GenericPlaceholder<?> genericPlaceholder) {
arguments[i] = Argument.ofTypeVariable(argument.getType(), argument.getName(), genericPlaceholder.getVariableName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
} else {
arguments[i] = Argument.of(argument.getType(), argument.getName(), wrappedArgumentAnnotationMetadata, argument.getTypeParameters());
}
}
}
return new MethodArguments(arguments, foundExpressions);
}
}

/**
Expand Down

0 comments on commit 889ed07

Please sign in to comment.