@Test public void generateUuidForRole_beginsWithAppropriatePrefix() { String regularUuid = CartManager.generateUuidForRole(LineItem.Role.REGULAR); String shippingUuid = CartManager.generateUuidForRole(LineItem.Role.SHIPPING); assertTrue(regularUuid.startsWith(CartManager.REGULAR_ID)); assertTrue(shippingUuid.startsWith(CartManager.SHIPPING_ID)); }
@NonNull static String generateUuidForRole(int role) { String baseId = UUID.randomUUID().toString(); String base = null; if (role == LineItem.Role.REGULAR) { base = REGULAR_ID; } else if (role == LineItem.Role.SHIPPING) { base = SHIPPING_ID; } StringBuilder builder = new StringBuilder(); if (base != null) { return builder.append(base) .append('-') .append(baseId.substring(base.length())) .toString(); } return baseId; }
CartManager { @NonNull static String generateUuidForRole(int role) { String baseId = UUID.randomUUID().toString(); String base = null; if (role == LineItem.Role.REGULAR) { base = REGULAR_ID; } else if (role == LineItem.Role.SHIPPING) { base = SHIPPING_ID; } StringBuilder builder = new StringBuilder(); if (base != null) { return builder.append(base) .append('-') .append(baseId.substring(base.length())) .toString(); } return baseId; } }
CartManager { @NonNull static String generateUuidForRole(int role) { String baseId = UUID.randomUUID().toString(); String base = null; if (role == LineItem.Role.REGULAR) { base = REGULAR_ID; } else if (role == LineItem.Role.SHIPPING) { base = SHIPPING_ID; } StringBuilder builder = new StringBuilder(); if (base != null) { return builder.append(base) .append('-') .append(baseId.substring(base.length())) .toString(); } return baseId; } CartManager();  CartManager(String currencyCode);  CartManager(@NonNull Cart oldCart);  CartManager(@NonNull Cart oldCart, boolean shouldKeepShipping, boolean shouldKeepTax); }
CartManager { @NonNull static String generateUuidForRole(int role) { String baseId = UUID.randomUUID().toString(); String base = null; if (role == LineItem.Role.REGULAR) { base = REGULAR_ID; } else if (role == LineItem.Role.SHIPPING) { base = SHIPPING_ID; } StringBuilder builder = new StringBuilder(); if (base != null) { return builder.append(base) .append('-') .append(baseId.substring(base.length())) .toString(); } return baseId; } CartManager();  CartManager(String currencyCode);  CartManager(@NonNull Cart oldCart);  CartManager(@NonNull Cart oldCart, boolean shouldKeepShipping, boolean shouldKeepTax); @Nullable String addLineItem(@NonNull @Size(min = 1) String description, long totalPrice); @Nullable String addLineItem(@NonNull @Size(min = 1) String description,
                              double quantity,
                              long unitPrice); @Nullable String addShippingLineItem(@NonNull @Size(min = 1) String description, long totalPrice); @Nullable String addShippingLineItem(@NonNull @Size(min = 1) String description,
                                      double quantity,
                                      long unitPrice); @Nullable Long calculateRegularItemTotal(); @Nullable Long calculateShippingItemTotal(); Long calculateTax(); void setTaxLineItem(@NonNull @Size(min = 1) String description, long totalPrice); void setTotalPrice(@Nullable Long totalPrice); void setTaxLineItem(@Nullable LineItem item); @Nullable LineItem removeLineItem(@NonNull @Size(min = 1) String itemId); @Nullable String addLineItem(@NonNull LineItem item); @NonNull Cart buildCart(); @Nullable Long getTotalPrice(); @NonNull Currency getCurrency(); @NonNull String getCurrencyCode(); @NonNull LinkedHashMap<String, LineItem> getLineItemsRegular(); @NonNull LinkedHashMap<String, LineItem> getLineItemsShipping(); @Nullable LineItem getLineItemTax(); }
CartManager { @NonNull static String generateUuidForRole(int role) { String baseId = UUID.randomUUID().toString(); String base = null; if (role == LineItem.Role.REGULAR) { base = REGULAR_ID; } else if (role == LineItem.Role.SHIPPING) { base = SHIPPING_ID; } StringBuilder builder = new StringBuilder(); if (base != null) { return builder.append(base) .append('-') .append(baseId.substring(base.length())) .toString(); } return baseId; } CartManager();  CartManager(String currencyCode);  CartManager(@NonNull Cart oldCart);  CartManager(@NonNull Cart oldCart, boolean shouldKeepShipping, boolean shouldKeepTax); @Nullable String addLineItem(@NonNull @Size(min = 1) String description, long totalPrice); @Nullable String addLineItem(@NonNull @Size(min = 1) String description,
                              double quantity,
                              long unitPrice); @Nullable String addShippingLineItem(@NonNull @Size(min = 1) String description, long totalPrice); @Nullable String addShippingLineItem(@NonNull @Size(min = 1) String description,
                                      double quantity,
                                      long unitPrice); @Nullable Long calculateRegularItemTotal(); @Nullable Long calculateShippingItemTotal(); Long calculateTax(); void setTaxLineItem(@NonNull @Size(min = 1) String description, long totalPrice); void setTotalPrice(@Nullable Long totalPrice); void setTaxLineItem(@Nullable LineItem item); @Nullable LineItem removeLineItem(@NonNull @Size(min = 1) String itemId); @Nullable String addLineItem(@NonNull LineItem item); @NonNull Cart buildCart(); @Nullable Long getTotalPrice(); @NonNull Currency getCurrency(); @NonNull String getCurrencyCode(); @NonNull LinkedHashMap<String, LineItem> getLineItemsRegular(); @NonNull LinkedHashMap<String, LineItem> getLineItemsShipping(); @Nullable LineItem getLineItemTax();  }