Java Reference
In-Depth Information
currentMfgr.getManufacturerId());
}
am.getManufacturerList().add(currentMfgr);
duplicate products E
Checks for
if (null == productMap.get(currentProduct.getProductId())) {
// this is a new product
pa = new ProductAccounts();
pa.setProduct(currentProduct);
productMap.put(currentProduct.getProductId(), pa);
productAccountList.add(pa);
} else {
// this prodcut has been loaded already
pa = productMap.get(currentProduct.getProductId());
}
// pa is now the current product's product / account list
pa.getAccountList().add(currentAccount);
am.getManufacturerList().add(currentMfgr);
}
ProductAccount beans F
Gets list of
public List<ProductAccounts> getProductAccountList() {
return productAccountList;
}
AccountManufacturer beans G
Gets list of
public List<AccountManufacturers> getAccountManufacturerList() {
return accountManufacturerList;
}
Gets product map H
public Map<Integer, ProductAccounts> getProductMap() {
return productMap;
}
Gets account map I
public Map<Integer, AccountManufacturers> getAccountMap() {
return accountMap;
}
}
Although the code here looks pretty complex, keep in mind that what it is doing is
also quite complex. We start with the one and only required method , and in it
we process the returned data to build the exact lists and maps that we want by keep-
ing only unique account objects , manufacturer objects , and product objects
, which we then expose to the caller using the getters ( , , , and ) on the
row handler. In addition, we provide object identity, so the account, product, and
manufacturer instances in all cases are the same objects. In other words, the account
with an ID value of 1 is the same instance of the account class in all of the data struc-
tures—therefore, a change to it will be reflected in all other places that it occurs.
b
C
D
E
FGH I
Search WWH ::




Custom Search