ObjectWriter class
Helper class to perform property introspection and dynamic writing.
In contrast to PropertyReflector which only introspects regular objects, this ObjectWriter 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 ObjectWriter treats all property names as case insensitive.
Example
var myObj = new MyObject();
ObjectWriter.setProperty(myObj, "myProperty", 123);
var myMap = { key1: 123, key2: "ABC" };
ObjectWriter.setProperty(myMap, "key1", "XYZ");
var myArray = [1, 2, 3]
ObjectWriter.setProperty(myArray, "0", 123);
Constructors
Properties
- hashCode → int
-
The hash code for this object. [...]
read-only, inherited
- runtimeType → Type
-
A representation of the runtime type of the object.
read-only, inherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed. [...]
inherited
-
toString(
) → String -
Returns a string representation of this object.
inherited
Operators
-
operator ==(
dynamic other) → bool -
The equality operator. [...]
inherited
Static Methods
-
setProperties(
dynamic obj, Map< String, dynamic> values) → void -
- Sets values of some (all) object properties.
- The object can be a user defined object, map or array.
- Property values correspondently are object properties,
- map key-pairs or array elements with their indexes.
- If some properties do not exist or introspection fails
- they are just silently skipped and no errors thrown.
-
obj
an object to write properties to.
-
values
a map, containing property names and their values.
- See setProperty
- Sets values of some (all) object properties.
-
setProperty(
dynamic obj String name, dynamic value) → void -
- Sets value of object property specified by its name.
- The object can be a user defined object, map or array.
- The property name correspondently must be object property,
- map key or array index.
- If the property does not exist or introspection fails
- this method doesn't do anything and doesn't any throw errors.
-
obj
an object to write property to.
-
name
a name of the property to set.
-
value
a new value for the property to set.
- Sets value of object property specified by its name.