@Override public Customer map(int index, ResultSet resultSet, StatementContext ctx) throws SQLException { Customer customer = new Customer(); customer.setId((UUID) resultSet.getObject("id")); customer.setSlug(resultSet.getString("slug")); customer.setEmail(resultSet.getString("email")); customer.setPhoneNumber(resultSet.getString("phone_number")); customer.setFirstName(resultSet.getString("first_name")); customer.setLastName(resultSet.getString("last_name")); customer.setCompany(resultSet.getString("company")); customer.setUserId((UUID) resultSet.getObject("agent_id")); return customer; } }
@Override public Optional<GatewayCustomerData> getCustomerData(Customer customer, String gatewayId) { GatewayCustomerData result = dao.getCustomerData(customer.getId(), gatewayId); if (result == null) { return Optional.absent(); } return Optional.of(result); }
private boolean updateCustomerIfNecessary(Customer existingCustomer, Customer customer) { boolean update = false; if (existingCustomer.getFirstName() == null || !existingCustomer.getFirstName().equals(customer.getFirstName())) { update = true; existingCustomer.setFirstName(customer.getFirstName()); } if (existingCustomer.getLastName() == null || !existingCustomer.getLastName().equals(customer.getLastName())) { update = true; existingCustomer.setLastName(customer.getLastName()); } if (existingCustomer.getPhoneNumber() == null || !existingCustomer.getPhoneNumber().equals(customer.getPhoneNumber())) { update = true; existingCustomer.setPhoneNumber(customer.getPhoneNumber()); } if (existingCustomer.getCompany() == null || !existingCustomer.getCompany().equals(customer.getCompany())) { update = true; existingCustomer.setCompany(customer.getCompany()); } return update; } }
public Component getListCellRendererComponent( JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { if (value instanceof Customer) { Customer c = (Customer) value; StringBuffer sb = new StringBuffer(); if (c.getCompany() != null && c.getCompany().length() > 0) { sb.append(c.getCompany()); } sb.append(" - "); if (c.getCompany() != null && c.getCompany().length() > 0) { sb.append(c.getContact()); } sb.append(" - "); if (c.getCompany() != null && c.getCompany().length() > 0) { sb.append(c.getCity()); sb.append(", "); } if (c.getCompany() != null && c.getCompany().length() > 0) { sb.append(c.getState()); } value = sb.toString(); } return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); } }
Customer customer = new Customer(); customer.setEmail(email); if (firstName != null) { customer.setFirstName(firstName); customer.setLastName(lastName); customer.setPhoneNumber((String) data.getFirst("phone")); customer.setCompany(company);
public CustomerRepresentation(Customer customer) { setEmail(customer.getEmail()); setFirstName(customer.getFirstName()); setLastName(customer.getLastName()); setPhoneNumber(customer.getPhoneNumber()); }
private Customer createCustomer(Customer customer) throws EntityAlreadyExistsException, InvalidEntityException, EntityDoesNotExistException { Customer actualCustomer; customer.setSlug(customer.getEmail()); if (this.customerStore.get().findBySlug(customer.getEmail()) == null) { actualCustomer = this.customerStore.get().create(customer); } else { Customer existingCustomer = this.customerStore.get().findBySlug(customer.getEmail()); boolean update = updateCustomerIfNecessary(existingCustomer, customer); if (update) { this.customerStore.get().update(existingCustomer); } actualCustomer = existingCustomer; } return actualCustomer; }
int currentCustomer = 3; // get the customer at 3 Customer c = list.get(currentCustomer); // change his email c.setEmail("somethingelse@example.com");
@Override public void onEvent(Event event, Object source, Object data) { final Order order = (Order) source; Map<String, Object> payload = Maps.newHashMap(); payload.put("customer", order.getCustomer().getEmail()); payload.put("order", order.getSlug()); webhooks.notifyHook(new OrderPaid(), payload); } }
customerMap.put("firstName", customer.getFirstName()); customerMap.put("lastName", customer.getLastName()); customerMap.put("email", customer.getEmail()); customerMap.put("phone", customer.getPhoneNumber()); context.put("customer", customerMap);
Map<String,Customer> customers = new HashMap<String,Customer>(); //somewhere in the code you fill up the Map, assuming customer names are unique customers.put(customer.getName(), customer) // at some later point you retrieve it like this; // this is fast, given a good hash // been calculated for the "keys" in your map, in this case the keys are unique // String objects so the default hash algorithm should be fine Customer theCustomerYouLookFor = customers.get("Doe"); // modify it theCustomerYouLookFor.setEmail("newEmail@stackoverflow.com")
prepareMailContext(order, customer, billingAddress, deliveryAddress, tenant, tenantLocale); String customerEmail = customer.getEmail();
Customer customer = new Customer(); customer.setId(order.getCustomerId()); customer.setSlug(resultSet.getString("customer_slug")); customer.setEmail(resultSet.getString("email")); customer.setFirstName(resultSet.getString("first_name")); customer.setLastName(resultSet.getString("last_name")); customer.setPhoneNumber(resultSet.getString("phone_number")); customer.setCompany(resultSet.getString("company")); order.setCustomer(customer); } catch (SQLException e) {
customerMap.put("firstName", customer.getFirstName()); customerMap.put("lastName", customer.getLastName()); customerMap.put("email", customer.getEmail()); customerMap.put("phone", customer.getPhoneNumber()); context.put("customer", customerMap);
@Override public Optional<GatewayCustomerData> getCustomerData(Customer customer, String gatewayId) { Key key = new Key(customer.getId(), gatewayId, "customer"); if (store.containsKey(key)) { return Optional.of((GatewayCustomerData) store.get(key)); } return Optional.absent(); }
@Override public void delete(@Valid Customer entity) throws EntityDoesNotExistException { Integer updatedRows = 0; this.dao.begin(); updatedRows += this.dao.deleteEntityEntityById(CUSTOMER_TABLE_NAME, entity.getId()); updatedRows += this.dao.detachChildren(entity.getId()); updatedRows += this.dao.deleteEntityAndChildrenById(entity.getId()); this.dao.commit(); if (updatedRows <= 0) { throw new EntityDoesNotExistException("No rows was updated when trying to delete customer"); } }
@Override public void supply(User user, Map<String, Object> data) { Customer customer = customerStore.get().findByUserId(user.getId()); if (customer == null) { return; } CustomerWebObject customerWebObject = new CustomerWebObject().withCustomer(customer); Address delivery = addressStore.get().findByCustomerIdAndType(customer.getId(), "delivery"); if (delivery != null) { customerWebObject.withDeliveryAddress(delivery); } Address billing = addressStore.get().findByCustomerIdAndType(customer.getId(), "billing"); if (billing != null) { customerWebObject.withBillingAddress(billing); } if (customer != null) { data.put("customer", customerWebObject); } } }
Customer customer = customerStore.get().findByUserId(webContext.getUser().getId()); if (customer != null) { Address deliveryAddress = addressStore.get().findByCustomerIdAndType(customer.getId(), "delivery"); Address billingAddress = addressStore.get().findByCustomerIdAndType(customer.getId(), "billing"); checkoutRequest = new CheckoutRequest(); checkoutRequest.setCustomer(customer);