Start by taking a look at Interfaces and Inheritance, basically an interface is a contract that gurentees that any object that implements that interface will provide the contractual functionality...
For example...
public interface CursorContainer {
public Cursor getCursor();
}
You "common" class would implement this interface and provide implementations for the getCursor (and any other required) method...
Class A implements CursorContainer {
public A (Cursor data){...}
}
Class B implements CursorContainer {
public B (Cursor data){...}
}
Class C implements CursorContainer {
public C (Cursor data){...}
}
Then you could use generics...
public void dataManipulation(ArrayList<CursorContainer> list, Cursor cursor){
Your next problem is know how to create a particular implementation, for this, you will need a factory...
public interface CursorContainerFactory {
public CursorContainer create(Cursor cursor);
}
You would need a factory for each type of container you want to create...
public Class CursorContainerAFactory implements CursorContainerFactory {
public CursorContainer create(Cursor cursor) {
return new A(cursor);
}
}
You would then need to supply the factory to your dataManipulation method...
public void dataManipulation(ArrayList<CursorContainer> list, CursorContainerFactory factory, Cursor cursor){
cursor.moveToFirst();
for (int i = 0; i < cursor.getCount(); i++) {
list(factory.create(cursor));
if (!cursor.isAfterLast())
cursor.moveToNext();
}
And finally, call it...
dataManipulation(listA, new CursorContainerAFactory(), cursor);
Remember, classes can implement many interfaces, but only extend from one...
A,BandCto implement which guarantees compatibility for the functionality that you requiremainmethod (which isn't the same aspublic static void main(String[] args), mind you). Also, what islist(new **?**(cursor))meant to represent?