I have an object that has a "getXXX" method. In this code here, the <FONT FACE=monospace>key</font> variable holds "XXX" (for the purposes of this question). The return type for this is "long". Not "Long", but primitive "long".<br><br>Depending on the type of <FONT FACE=monospace>c</font>, I want to fill the object using the "setXXX" method. To make sure my types agree, I check c's type through a series of if statements.<br><br>My question is, how do I check c against a primitive type? Or do I have to convert to a string and test it that way? Please tell me I can check the class itself without having an extra layer of conversion... )<br><br><FONT FACE=monospace>Class c = o.getClass().getMethod("get" + key, null).getReturnType();<br>Class[] parameterFiller={c};<br>if (c == Long.class) {<br> Long[] valueHolder = {Long.valueOf(value)};<br> o.getClass().getMethod("set"+key, parameterFiller).invoke(o, valueHolder);<br>} else if (c == String.class) {<br> String[] valueHolder = {value};<br> o.getClass().getMethod("set"+key, parameterFiller).invoke(o, valueHolder);<br>}</font><br><br>the above code doesn't work, because c is not of type "Long"... so when it gets to "if (c == Long.class)", that line gets skipped right over. How do I reference the primitive type?<br><br>thanks... <p>Liam Morley<br><a href=mailto:lmorley@wpi.edu>lmorley@wpi.edu</a><br><a href=] :: imotic :: website :: [</a><br>"light the deep, and bring silence to the world.<br>
light the world, and bring depth to the silence."
light the world, and bring depth to the silence."