I have a hierarchy where Square, Triangle and Circle all extend from Shape. I have a working method:
public void someMethod() {
File file = new File("File_with_squares");
ThirdPartyClass foo = new ThirdPartyClass();
Square[] squares = foo.someMajicMethod(Square[].class,file);
for (Square square: squares)
square.draw();
}
Now I want to make this method generic so that it can accept any shape. I want to be able to call it someMethod(Triangle.class,new File("File_with_triangles")
or someMethod(Circle.class, new File("File_with_circles")
. I am trying like this:
public void someMethod(Class<? extends Shape> type, File shapeFile) {
ThirdPartyClass foo = new ThirdPartyClass();
#### What goes here??? ####
for (Shape shape: shapes)
shape.draw();
}
What should be there at #### What goes here??? #### ???