5
I created a method that uses Reflection to run getters on top of an object, but I need to know if the class is native to JAVA, for example: java.lang.String, or whether it has been implemented by the user: br.com.foo.bar.
In PHP I can tell if it was the User who defined the class using the following:
$Reflectionclass = new Reflectionclass($classname);
$Reflectionclass->isUserDefined();
Would there be some way I could achieve this in JAVA without doing a lot of:
method.getReturnType() == String.class || method.getReturnType() == Integer.class
In java you have the
getClass()
of the object, which will return you the class. To compare you use the methodequals()
also of the object.– Dener
@Denie exactly what I don’t want to do, take the class and keep comparing with all the java natives.
– Luis Henrique
Ah yes now I understand
– Dener