forObject static method
Creates a Class instance for an object's runtime type.
Parameters:
obj
: The object to reflectdomain
: Optional protection domainpackage
: Optional package name to search with
Returns:
- A Class instance for the object's type
Implementation
static Class<Object> forObject(Object obj, [ProtectionDomain? domain, String? package]) {
try {
return Class.fromQualifiedName(ReflectionUtils.findQualifiedName(obj), domain ?? ProtectionDomain.system());
} on ClassNotFoundException catch (_) {
if(obj.runtimeType.toString().notEqualsIgnoreCase("type")) {
return _Class<Object>(obj.runtimeType.toString(), domain ?? ProtectionDomain.current(), package);
}
return _Class<Object>(obj.toString(), domain ?? ProtectionDomain.current(), package);
}
}