Sometimes you may need to populate one struct with the contents of two or more other structs.
A typical piece of Java code would look like the following:
BankBranchStruct dtls = new BankBranchStruct(); AddressDtls addressDtls = new AddressDtls(); BankBranchDtls bankBranchDtls = new BankBranchDtls(); // Copy from the "AddressDtls" struct dtls.addressLine1 = addressDtls.addressLine1; dtls.addressLine2 = addressDtls.addressLine2; dtls.addressLine3 = addressDtls.addressLine3; dtls.addressLine4 = addressDtls.addressLine4; dtls.cityCode = addressDtls.cityCode; dtls.countryCode = addressDtls.countryCode; dtls.postalCode = addressDtls.postalCode; dtls.regionCode = addressDtls.regionCode; dtls. addressVersionNo = addressDtls. versionNo ; // Copy from the "BankBranchDtls" struct dtls.bankBranchID = bankBranchDtls.bankBranchID; dtls.bankID = bankBranchDtls.bankID; dtls.bankSortCode = bankBranchDtls.bankSortCode; dtls.name = bankBranchDtls.name; dtls.versionNo = bankBranchDtls.versionNo;
By explicitly mapping the BankBranchStruct.addressVersionNo attribute to the Address.versionNo in the assignable relationship the Java can now be written as:
// Copy from the "AddressDtls" struct dtls.assign(addressDtls); // Copy from the "BankBranchDtls" struct dtls.assign(bankBranchDtls);
Note that in this case, the second assign does not overwrite the first as it happens to reference a different subset of fields, so the net effect is that the two struct contents are merged.