I think it's easier for you to make a single model class. In the class you describe the type (it is better to make enum), and Object is the object itself. Implement an ArrayList<КЛАСС МОДЕЛЬ> Add these models to the list, and where you need to process something, compare type from the model class and you know exactly what it will be for Object from the model class. Or use instanceof but he is known to be the slowest in java. This is your idea.
If you need to write the code. Or I do not quite understand what you mean.
Ok, let's start, I will take such simple examples.
Let's start with a small example.
We create our listings, in them you will describe your types.
package javaapplication21; public enum myType { checkBox, miscBox }
Create a model that will be used in ArrayList or where you need it.
public class myModel { myType type = null; Object value = null; public myModel(myType type, Object value){ this.type = type; this.value = value; } @Override public String toString(){ if(type==null)return null; return type.toString(); } }
You can then add all the standard functions such as eguals(сравнение двух моделей) .
Now we go where we will use it.
package javaapplication21; import java.util.ArrayList; public class JavaApplication21 { public static void main(String[] args) { ArrayList<myModel> models = new ArrayList<>(); models.add(new myModel(myType.checkBox, "Здесь ваш checkBox")); models.add(new myModel(myType.miscBox, "Здесь ваш miscBox")); //используем этот набор arraylist там где вам надо, пересылаете его и обрабатываете int a = 0; int max = models.size(); while(a!=max){ myModel model = models.get(a); if(model.type == myType.checkBox){ System.out.println("Я знаю что это checkBox"); } if(model.type == myType.miscBox){ System.out.println("Я знаю что это miscBox"); } a = a + 1; } } }
Everything is very simple, I use this method everywhere.