Package com.mparticle.commerce
Class Product
- java.lang.Object
-
- com.mparticle.commerce.Product
-
public final class Product extends java.lang.ObjectA 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.Builderclass to create a Product. Product objects are designed to be used withCommerceEvent.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProduct.BuilderThis class is designed to construct a Product object using the Builder pattern.static interfaceProduct.EqualityComparatorA simple interface that you can implement in order to customize Product equality comparisons.
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringADD_TO_CARTstatic java.lang.StringADD_TO_WISHLISTstatic java.lang.StringCHECKOUTstatic java.lang.StringCHECKOUT_OPTIONstatic java.lang.StringCLICKstatic java.lang.StringDETAILprotected longmTimeAddedstatic java.lang.StringPURCHASEstatic java.lang.StringREFUNDstatic java.lang.StringREMOVE_FROM_CARTstatic java.lang.StringREMOVE_FROM_WISHLIST
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object object)static ProductfromString(java.lang.String json)java.lang.StringgetBrand()java.lang.StringgetCategory()java.lang.StringgetCouponCode()java.util.Map<java.lang.String,java.lang.String>getCustomAttributes()java.lang.StringgetName()java.lang.IntegergetPosition()doublegetQuantity()java.lang.StringgetSku()doublegetTotalAmount()doublegetUnitPrice()java.lang.StringgetVariant()static voidsetEqualityComparator(Product.EqualityComparator comparator)Optionally customize the EqualityComparator.java.lang.StringtoString()
-
-
-
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:
equalsin 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:
toStringin classjava.lang.Object
-
fromString
@Nullable public static Product fromString(@NonNull java.lang.String json)
-
-