At the moment I have an ArrayDeque of a Tuple as follows (I thought having a class in this might help), which is currently serialized and sent over a network:
private ArrayDeque<Triple<Integer, Object, Class>> paramList = new ArrayDeque<>();
The object types in the Tuple can be primitive such as ints, bool or real classes such as Date, time (none of which are my implementations).
Right now I'm iterating through the list and calling the method depending on what class type it is, obviously this becomes tedious modify and update when. For example (st is PreparedStatement):
for (Triple<Integer, Object, Class> param : paramList) {
if(param.getMiddle() instanceof String){
st.setString(parm.getLeft(),param.getMiddle());
}else if(param.getMiddle() instanceof Integer){
st.setInt(parm.getLeft(),param.getMiddle());
} //... more class type checks doing the same thing
}
I came across this https://stackoverflow.com/a/5579385/5858208 post but as it's not classes I've implemented I can't really do much.
So my question is, is there a more efficient and maintainable way of implementing this idea since I have exactly what class-type it is in the tuple object?