How to put constructors and methods in the same list?
- Dominant language
- Java
- Stars
- 2k
- Forks
- 392
- Avg merge
- 11h 24m
- Merged PRs (30d)
- 36
Description
I want to save methods and constructors of any class under one list.
This is sample of what Im doing
private static List> GetMethodsnConstructor(CtModel model){
List> Allconstructornmethods = new ArrayList>();
List> constructors= model.getElements(new TypeFilter>(CtConstructor.class));
Allconstructornmethods = model.getElements(new TypeFilter>(CtMethod.class));
for(CtConstructor constructor: constructors)
{
if(!(constructor.isImplicit())) {
Allconstructornmethods.add((CtMethod)constructor);
}
}
return Allconstructornmethods;
}
Im saving it to Allconstructornmethods which is CtMethod Type list and getting an error at
Allconstructornmethods.add((CtMethod)constructor);
as error says I canot caste constructor to methods . is there any other way ?
thanks
Contributor guide
Assessment
This issue has not been assessed yet.