Open
Description
I want to save methods and constructors of any class under one list.
This is sample of what Im doing
private static List<CtMethod> GetMethodsnConstructor(CtModel model){
List> Allconstructornmethods = new ArrayList<CtMethod>();
List> constructors= model.getElements(new TypeFilter<CtConstructor>(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