I'm writing a Python script to parse Java classes from a backend service in order to extract necessary information. One of the things I need is to extract the request parameter from a java method.
public\s+[\w<>\[\]]+\s+(\w+)\s*\(([^{]+)(^(@ApiParam(.*)\))|^(@PathParam(.*))|^(@QueryParam(.*))|(@\w+\s+)?)((\w+)\s+(\w+))
Is what I got so far... It already gives me the method parameters in the brackets () however I cannot filter out the @ApiParam and @QueryParam annotations.
/*Some annotations*/
public PortfolioSuggestion calculatePortfolioSuggestion(
@ApiParam(required = true,
value = "Request containing the answers which were answered by the user and an\n" +
"investment for which suggestion should be calculated")
@Valid @NotNull PortfolioSuggestionRequest portfolioSuggestionRequest,
@ApiParam(value = "The optional product key")
@QueryParam("product") ProductType productType)
throws SuggestionsCalculationException {
The request parameter is always the first parameter which is not annotated with @ApiParam or @QueryParam. In this case my target would be PortfolioSuggestionRequest and portfolioSuggestionRequest. The annotations @Valid and @NotNull are always optional and could be omitted