Page History
Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Otp |
---|
Syntax |
| ||||||
---|---|---|---|---|---|---|---|
Semantics |
| ||||||
Substitutables | anInputObject , anotherInputObject | Can be any complex object having attributes of any type. | |||||
Examples |
|
Detailed Examples
Given are the two unrelated classes Person and DetailedPerson.
Image Modified Image Modified
mapEqualNames() | ||||||
---|---|---|---|---|---|---|
anInputPerson { } | The object anInputPerson is of type DetailedPerson. | |||||
| This statement assigns values to the matching attributes of object anOutputPerson { name: "Jane", surname: "Doe", city: "Los Angeles", street: "22, Main Road", zip: 90077 } |
mapEqualNamesIfExists() | ||||||
---|---|---|---|---|---|---|
aPerson { | The object aPerson of type Person already contains values.In our example, the zip code is unknown, so the attribute zip contains the value 0. | |||||
anotherInputPerson { | The object | |||||
| This statement assigns values to the matching attributes of object aPerson { name: "John", surname: "Smith", city: "New York", street: "65, Upper Eastside", zip: 12345 } The value of street remains unchanged, because in the source object it did not exist (was NULL). |
Usage of mapEqualNames() with append Statement
You can use the mapEqualNames()
macro along with the append statement to add a complex object with numerous attributes to an array of unrelated objects which needs only some of the information. The mapEqualNames()
macro will create set statements for all equal named attributes found in the target object while the append
statement will add the result to an array.
Given are the two unrelated classes Person and DetailedPerson.
Image Modified Image Modified
aDetailedPerson { | aDetailedPerson is provided from an external source. For further processing, we are interested in name and surname only. | ||
|
Result array: people [ {name: "John", surname: "Smith"; }{name: "Erica", surname: "Meyer"; }{name: "Jane", surname: "Doe"; } ] |
Panel | ||
---|---|---|
| ||
|