So I have a map:
Map format = new HashMap();
And I would add elements to it like this:
It is strange for me, that your compiler on line
Integer i = verifyType("100",format.get("Vendor Number"));
complains about unchecked invocation but doesn't show an error like "Type mismatch: cannot convert from Object to Integer".
This line just doesn't make sense to me. What do you expect verifyType to return if it receives Date.class as a second parameter? Also an Integer (then the return type of verifyType is invalid)? Or a Date? If you expect a Date, how is compiler expected to know that
format.get("Vendor Number");
returns Integer.class, but
format.get("Vendor Dispatch");
returns Date.class
Invocation of
Integer i = verifyType("100",format.get("Vendor Dispatch"));
must fail, as Date is not an Integer. So, in my opinion (and in opinion of my compiler) compilation of
Integer i = verifyType("100",format.get("Vendor Number"));
must fail.