Product { public static void setEqualityComparator(@Nullable EqualityComparator comparator) { if (comparator == null) { mComparator = new DefaultComparator(); } else { mComparator = comparator; } } private  Product(); private  Product(Builder builder); @Nullable Map<String, String> getCustomAttributes(); double getTotalAmount(); static void setEqualityComparator(@Nullable EqualityComparator comparator); @NonNull String getName(); @Nullable String getCategory(); @Nullable String getCouponCode(); @NonNull String getSku(); @Nullable Integer getPosition(); double getUnitPrice(); double getQuantity(); @Override boolean equals(@Nullable Object object); @Nullable String getBrand(); @Nullable String getVariant(); @NonNull @Override String toString(); @Nullable static Product fromString(@NonNull String json); @NonNull static final String ADD_TO_CART; @NonNull static final String REMOVE_FROM_CART; @NonNull static final String ADD_TO_WISHLIST; @NonNull static final String REMOVE_FROM_WISHLIST; @NonNull static final String CHECKOUT; @NonNull static final String CLICK; @NonNull static final String DETAIL; @NonNull static final String PURCHASE; @NonNull static final String REFUND; @NonNull static final String CHECKOUT_OPTION; }
@Test public void testDefaultEqualityComparator() { Product.setEqualityComparator(null); Product product1 = new Product.Builder("name", "sku",2).brand("cool brand!").build(); Product product2 = new Product.Builder("cool brand!", "sku",2).brand("cool brand!adsflkjh").build(); Product product2Copy = new Product.Builder(product2).build(); product2Copy.mTimeAdded = product2.mTimeAdded; assertNotEquals(product2, product1); assertEquals(product1, product1); assertEquals(product2, product2Copy); assertNotEquals(product1, null); assertNotEquals(null, product1); }