0

I am using javaparser to parse and analyse some classes and to generate an adequate response. I have a problem detecting if a method's argument is an enum.

A class is parsed and list of methods is fetched. When I iterate through this list I also fetch arguments of these methods. Then I have a problem finding out which of these are enums. For instance:

... 
Collection<MethodDeclaration> methods = parsed.getMethods();
int numberOfEnums = methods.stream().map(parameter -> {
    if(<detect here if parameter is an enum>) {
        return 1;
    }
    return 0;
}).reduce(0, (a, b) -> a + b);

Parameter in the stream is of type com.github.javaparser.ast.body.Parameter. This is just a simple example of an usage (reporting on how many enums are in the method arguments). However, I need it for something much more complex.

Analyzed source is a java code file, which means, in a general case, we cannot assume a parameter class is reachable in the current VM's class-path.

Saša
  • 4,416
  • 1
  • 27
  • 41

0 Answers0