![]() |
|||||
|
How to set/retrieve reference values?In compliance with the JMI specification the generator has created typed reference accessor operations for every reference originating from the modeled class. By using these accessor operations you have a simple, type-safe way
The following example shows how to retrieve the referenced objects for a given reference. Example 4-7. Retrieve group instances of the reference group of a Person instance // retrieve all group instances Collection groups = person.getGroup(); // retrieve the group instance at the specified index // only for references stored as attribute Group group = person.getGroup(index); // retrieve the address instance for a specified qualifier (priority) // only for references not stored as attribute Address address = person.getAddress(priority); The following example shows how to add a new object to a given reference. Example 4-8. Add a group instance to the reference group of a Person instance // add a specified group instance person.addGroup(group); // add a specified group instance at the specified index // only for references stored as attribute person.addGroup(index, group); // add a specified address instance for a specified qualifier (priority) // only for references not stored as attribute person.addAddress(priority, address); The following example shows how to remove an existing object from a given reference. Example 4-9. Remove a group instance from the reference group of a Person instance // remove a specified group instance person.removeGroup(group); // remove the group instance at the specified index // only for references stored as attribute person.removeGroup(index); // remove the address instance for a specified qualifier (priority) // only for references not stored as attribute person.removeAddress(priority);
|
||||