java.lang.Object
com.broadleafcommerce.subscriptionoperation.domain.Variant
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable, com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class Variant extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware, com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable

Variants can help further identify the specifics of a Product by narrowing down the Sku via additional user data.

Variants are only intended to be accessed within the context of a Product and only provide a link to the Product it is apart of because of this.

Author:
Phillip Verheyden (phillipuniverse)
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Variant(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, boolean online, boolean discountable, String productId, Map<String,String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, Integer minimumThreshold, Integer maximumThreshold, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
    Creates a new Variant instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
     
    boolean
     
    When this Variant should no longer be active.
    When this Variant should start to become active.
    com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
    A subset of Tracking information to expose the context state for this object.
    javax.money.MonetaryAmount
    Can be used in display or as apart of more complex pricing algorithms
    javax.money.MonetaryAmount
    The default price that should be used if there is not a salePrice set.
    Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.
    This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
    The unique identifier for this variant.
    Describes when the variant's inventory should be checked for availability.
    Describes when the variant's inventory should be reserved.
    The maximum count of this variant can be added in a cart.
    The minimum count of this variant that must be added in a cart.
    The name of this particular variant of the product.
    Helper to make this particular variant uniquely identifiable across multiple variants for the same product.
    com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer
     
    The link to the product that this variant is a part of
    javax.money.MonetaryAmount
    Indicates that this product is on sale.
    Sku code for this particular variant.
    The tax code for this variant.
    Universal product code that defines this particular variant of the product
    int
     
    boolean
    Inactive variants are by default NOT searchable, NOT browseable, and NOT purchaseable.
    boolean
    Whether or not this variant can participate in offers or promotions
    boolean
    Whether or not this variant should be visible at all in the store.
    boolean
    An item is on sale if both getDefaultPrice() and getSalePrice() are both set
    void
    setActiveEndDate(Instant activeEndDate)
    When this Variant should no longer be active.
    void
    setActiveStartDate(Instant activeStartDate)
    When this Variant should start to become active.
    void
    setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
    A subset of Tracking information to expose the context state for this object.
    void
    setCost(javax.money.MonetaryAmount cost)
    Can be used in display or as apart of more complex pricing algorithms
    void
    setDefaultPrice(javax.money.MonetaryAmount defaultPrice)
    The default price that should be used if there is not a salePrice set.
    void
    setDescription(String description)
    Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.
    void
    setDiscountable(boolean discountable)
    Whether or not this variant can participate in offers or promotions
    void
    setExternalId(String externalId)
    This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
    void
    The unique identifier for this variant.
    void
    setInventoryCheckStrategy(String inventoryCheckStrategy)
    Describes when the variant's inventory should be checked for availability.
    void
    setInventoryReservationStrategy(String inventoryReservationStrategy)
    Describes when the variant's inventory should be reserved.
    void
    setMaximumThreshold(Integer maximumThreshold)
    The maximum count of this variant can be added in a cart.
    void
    setMinimumThreshold(Integer minimumThreshold)
    The minimum count of this variant that must be added in a cart.
    void
    The name of this particular variant of the product.
    void
    setOnline(boolean online)
    Whether or not this variant should be visible at all in the store.
    void
    Helper to make this particular variant uniquely identifiable across multiple variants for the same product.
    void
    setOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
     
    void
    setProductId(String productId)
    The link to the product that this variant is a part of
    void
    setSalePrice(javax.money.MonetaryAmount salePrice)
    Indicates that this product is on sale.
    void
    Sku code for this particular variant.
    void
    setTaxCode(String taxCode)
    The tax code for this variant.
    void
    Universal product code that defines this particular variant of the product
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Variant

      public Variant(String id, String sku, String upc, String externalId, String name, String description, Instant activeStartDate, Instant activeEndDate, javax.money.MonetaryAmount defaultPrice, javax.money.MonetaryAmount salePrice, javax.money.MonetaryAmount cost, boolean online, boolean discountable, String productId, Map<String,String> optionValues, String inventoryCheckStrategy, String inventoryReservationStrategy, Integer minimumThreshold, Integer maximumThreshold, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState, String taxCode, com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
      Creates a new Variant instance.
      Parameters:
      id - the context ID of the variant
      sku - the SKU code for this variant
      upc - the universal product code for this variant
      externalId - an external ID, often a DB or business ID, from a system outside of Broadleaf
      name - the name of this variant
      description - of this Variant with HTML if necessary
      activeStartDate - the date on which this variant should become active
      activeEndDate - the date on which this variant should stop being active
      defaultPrice - the default price to be used for this variant
      salePrice - the sale price of this variant, indicating it is on sale
      cost - the cost of this variant
      online - whether or not this variant is visible in the store
      discountable - whether or not this variant can participate in offers or promotions
      productId - the context ID of the product that this variant is associated with
      optionValues - a map of option attribute names to a corresponding option value
      inventoryCheckStrategy - a String representation of InventoryCheckStrategy
      inventoryReservationStrategy - a String representation of InventoryReservationStrategy
      minimumThreshold - the minimum count of this variant that must be added in a cart
      maximumThreshold - the maximum count of this variant can be added in a cart
      contextState - a subset of Tracking information to expose the context state for this object
      taxCode - The tax code for this variant.
      overrideChangeContainer -
    • Variant

      public Variant()
  • Method Details

    • isActive

      public boolean isActive()
      Inactive variants are by default NOT searchable, NOT browseable, and NOT purchaseable.
      Returns:
      the active state of this current variant
      See Also:
    • isOnSale

      public boolean isOnSale()
      An item is on sale if both getDefaultPrice() and getSalePrice() are both set
      Returns:
      whether or not the item is on sale
    • getId

      public String getId()
      The unique identifier for this variant.
      Returns:
      the context ID of the variant
    • getSku

      public String getSku()
      Sku code for this particular variant. Overrides the main Product Sku that is set, if any
      Returns:
      the SKU code for this variant
    • getUpc

      public String getUpc()
      Universal product code that defines this particular variant of the product
      Returns:
      the universal product code for this variant
    • getExternalId

      public String getExternalId()
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Returns:
      an external ID
    • getName

      public String getName()
      The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order
      Returns:
      the name of this variant
    • getDescription

      public String getDescription()
      Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.
      Returns:
      the description of this Variant, can contain HTML
    • getActiveStartDate

      public Instant getActiveStartDate()
      When this Variant should start to become active. Unset to mark this Variant as always active
      Returns:
      the date on which this variant should become active
      See Also:
    • getActiveEndDate

      public Instant getActiveEndDate()
      When this Variant should no longer be active. Unset to mark this variant as never inactive
      Returns:
      the date on which this variant should stop being active
      See Also:
    • getDefaultPrice

      public javax.money.MonetaryAmount getDefaultPrice()
      The default price that should be used if there is not a salePrice set. This price can also be maintained at the Product level
      Returns:
      the default price to be used for this variant
    • getSalePrice

      public javax.money.MonetaryAmount getSalePrice()
      Indicates that this product is on sale. This should take priority over the default price if the default price is lower
      Returns:
      the sale price of this variant, indicating it is on sale
    • getCost

      public javax.money.MonetaryAmount getCost()
      Can be used in display or as apart of more complex pricing algorithms
      Returns:
      the cost of this variant
    • isOnline

      public boolean isOnline()

      Whether or not this variant should be visible at all in the store. A variant that is offline is not searchable, visible, or purchasable. A variant that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.

      Defaults to true

      Returns:
      whether or not this variant is visible in the store
    • isDiscountable

      public boolean isDiscountable()
      Whether or not this variant can participate in offers or promotions
      Returns:
      whether or not this variant can participate in offers or promotions
    • getProductId

      public String getProductId()
      The link to the product that this variant is a part of
      Returns:
      the context ID of the product that this variant is associated with
    • getOptionValues

      public Map<String,String> getOptionValues()
      Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond to AttributeChoice#attributeName while values correspond to one of the corresponding AttributeChoice#allowedValues.
      Returns:
      a map of option attribute names to a corresponding option value
    • getInventoryCheckStrategy

      public String getInventoryCheckStrategy()
      Describes when the variant's inventory should be checked for availability. If not set, defaults to Product#inventoryCheckStrategy.
      Returns:
      the variant's inventory check strategy
      See Also:
      • InventoryCheckStrategy
    • getInventoryReservationStrategy

      public String getInventoryReservationStrategy()
      Describes when the variant's inventory should be reserved. If not set, defaults to Product#inventoryReservationStrategy.
      Returns:
      the variant's inventory reservation strategy
      See Also:
      • InventoryReservationStrategy
    • getMinimumThreshold

      public Integer getMinimumThreshold()
      The minimum count of this variant that must be added in a cart.
      Returns:
      the minimum count of this variant that must be added in a cart
    • getMaximumThreshold

      public Integer getMaximumThreshold()
      The maximum count of this variant can be added in a cart.
      Returns:
      the maximum count of this variant can be added in a cart
    • getContextState

      public com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState getContextState()
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      getContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Returns:
      a subset of Tracking information to expose the context state for this object
    • getTaxCode

      public String getTaxCode()
      The tax code for this variant.
      Returns:
      The tax code for this variant.
    • getOverrideChangeContainer

      public com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer getOverrideChangeContainer()
      Specified by:
      getOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • setId

      public void setId(String id)
      The unique identifier for this variant.
      Parameters:
      id - the context ID of the variant
    • setSku

      public void setSku(String sku)
      Sku code for this particular variant. Overrides the main Product Sku that is set, if any
      Parameters:
      sku - the SKU code for this variant
    • setUpc

      public void setUpc(String upc)
      Universal product code that defines this particular variant of the product
      Parameters:
      upc - the universal product code for this variant
    • setExternalId

      public void setExternalId(String externalId)
      This is an arbitrary ID, typically assigned by or used by 1st or 3rd party systems that are not Broadleaf.
      Parameters:
      externalId - an external ID, often a DB or business ID, from a system outside of Broadleaf
    • setName

      public void setName(String name)
      The name of this particular variant of the product. Generally serves as an overridable field from a product. During option selection when narrowing the specific Sku to order
      Parameters:
      name - the name of this variant
    • setDescription

      public void setDescription(String description)
      Description of the Variant that can include HTML in implementations where a WYSIWYG editor manages this field.
      Parameters:
      description - of this Variant with HTML if necessary
    • setActiveStartDate

      public void setActiveStartDate(Instant activeStartDate)
      When this Variant should start to become active. Unset to mark this Variant as always active
      Parameters:
      activeStartDate - the date on which this variant should become active
      See Also:
    • setActiveEndDate

      public void setActiveEndDate(Instant activeEndDate)
      When this Variant should no longer be active. Unset to mark this variant as never inactive
      Parameters:
      activeEndDate - the date on which this variant should stop being active
      See Also:
    • setDefaultPrice

      public void setDefaultPrice(javax.money.MonetaryAmount defaultPrice)
      The default price that should be used if there is not a salePrice set. This price can also be maintained at the Product level
      Parameters:
      defaultPrice - the default price to be used for this variant
    • setSalePrice

      public void setSalePrice(javax.money.MonetaryAmount salePrice)
      Indicates that this product is on sale. This should take priority over the default price if the default price is lower
      Parameters:
      salePrice - the sale price of this variant, indicating it is on sale
    • setCost

      public void setCost(javax.money.MonetaryAmount cost)
      Can be used in display or as apart of more complex pricing algorithms
      Parameters:
      cost - the cost of this variant
    • setOnline

      public void setOnline(boolean online)

      Whether or not this variant should be visible at all in the store. A variant that is offline is not searchable, visible, or purchasable. A variant that is offline behaves as if it falls outside the active date range. It is not returned from storefront requests by default.

      Defaults to true

      Parameters:
      online - whether or not this variant is visible in the store
    • setDiscountable

      public void setDiscountable(boolean discountable)
      Whether or not this variant can participate in offers or promotions
      Parameters:
      discountable - whether or not this variant can participate in offers or promotions
    • setProductId

      public void setProductId(String productId)
      The link to the product that this variant is a part of
      Parameters:
      productId - the context ID of the product that this variant is associated with
    • setOptionValues

      public void setOptionValues(Map<String,String> optionValues)
      Helper to make this particular variant uniquely identifiable across multiple variants for the same product. Keys correspond to AttributeChoice#attributeName while values correspond to one of the corresponding AttributeChoice#allowedValues.
      Parameters:
      optionValues - a map of option attribute names to a corresponding option value
    • setInventoryCheckStrategy

      public void setInventoryCheckStrategy(String inventoryCheckStrategy)
      Describes when the variant's inventory should be checked for availability. If not set, defaults to Product#inventoryCheckStrategy.
      Parameters:
      inventoryCheckStrategy - a String representation of InventoryCheckStrategy
      See Also:
      • InventoryCheckStrategy
    • setInventoryReservationStrategy

      public void setInventoryReservationStrategy(String inventoryReservationStrategy)
      Describes when the variant's inventory should be reserved. If not set, defaults to Product#inventoryReservationStrategy.
      Parameters:
      inventoryReservationStrategy - a String representation of InventoryReservationStrategy
      See Also:
      • InventoryReservationStrategy
    • setMinimumThreshold

      public void setMinimumThreshold(Integer minimumThreshold)
      The minimum count of this variant that must be added in a cart.
      Parameters:
      minimumThreshold - the minimum count of this variant that must be added in a cart
    • setMaximumThreshold

      public void setMaximumThreshold(Integer maximumThreshold)
      The maximum count of this variant can be added in a cart.
      Parameters:
      maximumThreshold - the maximum count of this variant can be added in a cart
    • setContextState

      public void setContextState(com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
      A subset of Tracking information to expose the context state for this object.
      Specified by:
      setContextState in interface com.broadleafcommerce.data.tracking.core.ContextStateAware
      Parameters:
      contextState - a subset of Tracking information to expose the context state for this object
    • setTaxCode

      public void setTaxCode(String taxCode)
      The tax code for this variant.
      Parameters:
      taxCode - The tax code for this variant.
    • setOverrideChangeContainer

      public void setOverrideChangeContainer(com.broadleafcommerce.data.tracking.core.filtering.domain.ChangeContainer overrideChangeContainer)
      Specified by:
      setOverrideChangeContainer in interface com.broadleafcommerce.data.tracking.core.ChangeContainerOverridable
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • canEqual

      protected boolean canEqual(Object other)
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object