Packageorg.pranaframework.utils
Classpublic class ObjectUtils

ObjectsUtils contains utility methods for working with objects.



Public Methods
 MethodDefined by
  
clone(object:Object):*
[static]
ObjectUtils
  
getClassInfo(object:Object):Object
[static] Wraps ObjectUtil.getClassInfo() and adds support for the following primitive types: String, Number, int, uint, Boolean, Date and Array.
ObjectUtils
  
isExplicitInstanceOf(object:Object, clazz:Class):Boolean
[static] Checks if the given object is an explicit instance of the given class.
ObjectUtils
  
toInstance(object:Object, clazz:Class):*
[static] Converts a plain vanilla object to be an instance of the class passed as the second variable.
ObjectUtils
Method detail
clone()method
public static function clone(object:Object):*Parameters
object:Object

Returns
*
getClassInfo()method 
public static function getClassInfo(object:Object):Object

Wraps ObjectUtil.getClassInfo() and adds support for the following primitive types: String, Number, int, uint, Boolean, Date and Array.

Parameters
object:Object

Returns
Object
isExplicitInstanceOf()method 
public static function isExplicitInstanceOf(object:Object, clazz:Class):Boolean

Checks if the given object is an explicit instance of the given class.

That means that true will only be returned if the object was instantiated directly from the given class.

Parameters
object:Object — the object to check
 
clazz:Class — the class from which the object should be an explicit instance

Returns
Boolean — true if the object is an explicit instance of the class, false if not
toInstance()method 
public static function toInstance(object:Object, clazz:Class):*

Converts a plain vanilla object to be an instance of the class passed as the second variable. This is not a recursive funtion and will only work for the first level of nesting. When you have deeply nested objects, you first need to convert the nested objects to class instances, and then convert the top level object. TODO: This method can be improved by making it recursive. This would be done by looking at the typeInfo returned from describeType and determining which properties represent custom classes. Those classes would then be registerClassAlias'd using getDefinititonByName to get a reference, and then objectToInstance would be called on those properties to complete the recursive algorithm.

Parameters
object:Object — The plain object that should be converted
 
clazz:Class — The type to convert the object to

Returns
*