/** * Obtains the name of all the furniture models available for a certain type of furniture, within * the active catalog * * @param furnitureTypeName The type of furniture whose models we want * @return A collection of strings containing all the names of the particular models of * 'furnitureTypeName' */ public Collection<String> getFurnitureModelNames(String furnitureTypeName) { Collection<FurnitureModel> fmodels = getFurnitureModels(furnitureTypeName); Collection<String> furnitureNames = new ArrayList(); for (FurnitureModel fm : fmodels) { furnitureNames.add(fm.getName()); } return furnitureNames; }
/** Obtains a particular model as such. Used internally */ private FurnitureModel getModel(String furnitureTypeName, String name) { // If the model is chached, we return it if (cached_fm != null && cached_fm.getType().equals(furnitureTypeName) && cached_fm.getName().equals(name)) ; // Else, we find it and cache it! else { boolean wasFound = false; for (FurnitureModel fm : getFurnitureModels(furnitureTypeName)) if (fm.getName().equals(name)) { cached_fm = fm; wasFound = true; break; } if (!wasFound) throw new ElementNotFoundBusinessException(null); } return cached_fm; }