public Object[] convertTo(Map source, Object[] destination) {
...
}
Is there a possibility to figure out the generic types (key / value) of my Map parameter via Reflection?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given a
Map<Key,Value>, it isn’t possible to figure outKeyandValueat runtime. This is due to type erasure (also, see Wikipedia).It is, however, possible to examine each object (key or value) contained in the map, and call their
getClass()method. This will tell you the runtime type of that object. Note that this still won’t tell you anything about the compile-type typesKeyandValue.