Is Type Compatible
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
public class Utils {
public static boolean isTypeCompatible(Class formalType, Class actualType, boolean strict) {
if (formalType == null && actualType != null)
return false;
if (formalType != null && actualType == null)
return false;
if (formalType == null && actualType == null)
return true;
if (strict)
return formalType.equals(actualType);
else
return formalType.isAssignableFrom(actualType);
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
Reflection Class:
- Class modifier: public, abstract or final
- Class simple name plus package name
- Create new instance
- Class reflection, all methods, constructors, parameters, interfaces
- Get super class name
- Get the class By way of .class
- Get unqualified class Name
- Is Type Compatible
- Is Primitive type
- Load a class given its name.