Package com.mparticle.commerce
Class Product
- java.lang.Object
-
- com.mparticle.commerce.Product
-
public final class Product extends java.lang.Object
A Product represents any good or service that a user may purchase, view, or otherwise interact with in your app. The Product class is built to be immutable - use theProduct.Builder
class to create a Product. Product objects are designed to be used withCommerceEvent
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Product.Builder
This class is designed to construct a Product object using the Builder pattern.static interface
Product.EqualityComparator
A simple interface that you can implement in order to customize Product equality comparisons.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ADD_TO_CART
static java.lang.String
ADD_TO_WISHLIST
static java.lang.String
CHECKOUT
static java.lang.String
CHECKOUT_OPTION
static java.lang.String
CLICK
static java.lang.String
DETAIL
protected long
mTimeAdded
static java.lang.String
PURCHASE
static java.lang.String
REFUND
static java.lang.String
REMOVE_FROM_CART
static java.lang.String
REMOVE_FROM_WISHLIST
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object object)
static Product
fromString(java.lang.String json)
java.lang.String
getBrand()
java.lang.String
getCategory()
java.lang.String
getCouponCode()
java.util.Map<java.lang.String,java.lang.String>
getCustomAttributes()
java.lang.String
getName()
java.lang.Integer
getPosition()
double
getQuantity()
java.lang.String
getSku()
double
getTotalAmount()
double
getUnitPrice()
java.lang.String
getVariant()
static void
setEqualityComparator(Product.EqualityComparator comparator)
Optionally customize the EqualityComparator.java.lang.String
toString()
-
-
-
Field Detail
-
ADD_TO_CART
@NonNull public static final java.lang.String ADD_TO_CART
- See Also:
- Constant Field Values
-
REMOVE_FROM_CART
@NonNull public static final java.lang.String REMOVE_FROM_CART
- See Also:
- Constant Field Values
-
ADD_TO_WISHLIST
@NonNull public static final java.lang.String ADD_TO_WISHLIST
- See Also:
- Constant Field Values
-
REMOVE_FROM_WISHLIST
@NonNull public static final java.lang.String REMOVE_FROM_WISHLIST
- See Also:
- Constant Field Values
-
CHECKOUT
@NonNull public static final java.lang.String CHECKOUT
- See Also:
- Constant Field Values
-
CLICK
@NonNull public static final java.lang.String CLICK
- See Also:
- Constant Field Values
-
DETAIL
@NonNull public static final java.lang.String DETAIL
- See Also:
- Constant Field Values
-
PURCHASE
@NonNull public static final java.lang.String PURCHASE
- See Also:
- Constant Field Values
-
REFUND
@NonNull public static final java.lang.String REFUND
- See Also:
- Constant Field Values
-
CHECKOUT_OPTION
@NonNull public static final java.lang.String CHECKOUT_OPTION
- See Also:
- Constant Field Values
-
mTimeAdded
protected long mTimeAdded
-
-
Method Detail
-
getCustomAttributes
@Nullable public java.util.Map<java.lang.String,java.lang.String> getCustomAttributes()
- Returns:
- Retrieve the Map of custom attributes set on this Product
- See Also:
Product.Builder.customAttributes(Map)
-
getTotalAmount
public double getTotalAmount()
-
setEqualityComparator
public static void setEqualityComparator(@Nullable Product.EqualityComparator comparator)
Optionally customize the EqualityComparator. If the comparator is null, the default comparator will be restored. The default comparator compares Products by their toString() value.- Parameters:
comparator
-
-
getName
@NonNull public java.lang.String getName()
- Returns:
- the name description of the Product
-
getCategory
@Nullable public java.lang.String getCategory()
- Returns:
- the category description of the Product
-
getCouponCode
@Nullable public java.lang.String getCouponCode()
- Returns:
- the coupon code associated with the Product
-
getSku
@NonNull public java.lang.String getSku()
- Returns:
- the SKU/ID associated with the Product
-
getPosition
@Nullable public java.lang.Integer getPosition()
- Returns:
- the position of the product on the page/product impression list
-
getUnitPrice
public double getUnitPrice()
- Returns:
- the unit price of a single Product
-
getQuantity
public double getQuantity()
- Returns:
- the quantity of Products
-
equals
public boolean equals(@Nullable java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
getBrand
@Nullable public java.lang.String getBrand()
- Returns:
- the brand of the Product
-
getVariant
@Nullable public java.lang.String getVariant()
- Returns:
- the variant or version of the Product
-
toString
@NonNull public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
fromString
@Nullable public static Product fromString(@NonNull java.lang.String json)
-
-