I want to have my models wrapped up in a ModelCollection which is mostly used for a ListView. The Collection has always the same attributes like title, totalResults (for Pagination) and it shall contain the listItem-Models in the ArrayList "items". However, these models have different types like "ModelCategory" or "ModelChain" and often have different Properties and Methods.
How can I achieve this in java with strong Typing discipline? I heart interface a the right way to do this. WHERE do I have to implement them?
public class ModelCollection {
public ArrayList< ModelCategory OR ModelChain OR ModelXyz> items = new ArrayList<ModelCategory OR ModelChain OR ModelXyz>();
private String id;
private String title;
private Long updated;
private String linkSelf;
private int totalResults;
private int startIndex;
/*
more stuff like parsing a feed
*/
}