ObjectReader class
Helper class to perform property introspection and dynamic reading.
In contrast to PropertyReflector which only introspects regular objects, this ObjectReader is also able to handle maps and arrays. For maps properties are key-pairs identified by string keys, For arrays properties are elements identified by integer index.
This class has symmetric implementation across all languages supported by Pip.Services toolkit and used to support dynamic data processing.
Because all languages have different casing and case sensitivity rules, this ObjectReader treats all property names as case insensitive. See PropertyReflector
Example
var myObj = MyObject();
var properties = ObjectReader.getPropertyNames();
ObjectReader.hasProperty(myObj, 'myProperty');
var value = PropertyReflector.getProperty(myObj, 'myProperty');
var myMap = { 'key1': 123, 'key2': 'ABC' };
ObjectReader.hasProperty(myMap, 'key1');
var value = ObjectReader.getProperty(myMap, 'key1');
var myArray = [1, 2, 3]
ObjectReader.hasProperty(myArrat, '0');
var value = ObjectReader.getProperty(myArray, '0');
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
getProperties(
dynamic obj) → Map< String, dynamic> - Get values of all properties in specified object and returns them as a map.
-
getProperty(
dynamic obj, String? name) → dynamic - Gets value of object property specified by its name.
-
getPropertyNames(
dynamic obj) → List< String> - Gets names of all properties implemented in specified object.
-
getValue(
dynamic obj) → dynamic - Gets a real object value. If object is a wrapper, it unwraps the value behind it. Otherwise it returns the same object value.
-
hasProperty(
dynamic obj, String? name) → bool - Checks if object has a property with specified name.