/** * @param customerName * @return Customer associated by the given name, or null if the customer cannot be found. */ public Customer findCustomerByNameAndType(String customerName, PowerType type) { for (Entry<CustomerInfo, Customer> entry : customerMap.entrySet()) { CustomerInfo key = entry.getKey(); Customer value = entry.getValue(); if (key.getName().equals(customerName) && (key.getPowerType() == type)) { return value; } } return null; }
/** Creates and adds a customer object into the map. Map key will be a given customerInfo. */ public void addCustomers(List<CustomerInfo> customerInfos) { for (CustomerInfo customerInfo : customerInfos) { Customer customer = new Customer(customerInfo); customerMap.put(customerInfo, customer); PowerType genericType = customerInfo.getPowerType().getGenericType(); if (genericType == PowerType.CONSUMPTION) { consumers.add(customer); } else if (genericType == PowerType.PRODUCTION) { producers.add(customer); } else if (genericType == PowerType.STORAGE) { storages.add(customer); } } // build list: customerList = new ArrayList<Customer>(customerMap.values()); log.info( "Customers added: List size:" + customerList.size() + " Map size:" + customerMap.size()); }