public Customer getCustomerByName(String name) throws NoSuchCustomerException { Customer customer = customers.get(name); if (customer == null) { NoSuchCustomer noSuchCustomer = new NoSuchCustomer(); noSuchCustomer.setCustomerName(name); throw new NoSuchCustomerException("Did not find any matching customer for name=" + name, noSuchCustomer); } return customer; } }
public List<Customer> getCustomersByName(String name) throws NoSuchCustomerException { if ("None".equals(name)) { NoSuchCustomer noSuchCustomer = new NoSuchCustomer(); noSuchCustomer.setCustomerName(name); throw new NoSuchCustomerException("Did not find any matching customer for name=" + name, noSuchCustomer); } List<Customer> customers = new ArrayList<Customer>(); for (int c = 0; c < 2; c++) { Customer cust = new Customer(); cust.setName(name); cust.getAddress().add("Pine Street 200"); Date bDate = new GregorianCalendar(2009, 01, 01).getTime(); cust.setBirthDate(bDate); cust.setNumOrders(1); cust.setRevenue(1000); cust.setTest(new BigDecimal(1.5)); cust.setType(CustomerType.BUSINESS); customers.add(cust); } return customers; }