Class SpecificItemChoice

java.lang.Object
com.broadleafcommerce.catalogbrowse.domain.SpecificItemChoice
All Implemented Interfaces:
Priceable, Serializable

public class SpecificItemChoice extends Object implements Serializable, Priceable
When a ItemChoice is determined to be a DefaultItemChoiceTargetType.SPECIFIC_PRODUCTS or DefaultItemChoiceTargetType.SPECIFIC_VARIANTS, this holds the relationship that the customer should select from
Author:
Nathan Moore (nathandmoore)
See Also:
  • Constructor Details

    • SpecificItemChoice

      public SpecificItemChoice()
  • Method Details

    • getVendorRef

      @Nullable public String getVendorRef()
    • addAttribute

      public void addAttribute(String name, Object value)
      Takes in any additional attributes passed in the request not matching any defined properties.
      Parameters:
      name - Name of the additional attribute
      value - Value of the additional attribute
    • getAttribute

      public Map<String,Object> getAttribute()
      Return any additional attributes passed in the request not matching any defined properties.
      Returns:
      any additional attributes passed in the request not matching any defined properties.
    • getPricingKey

      public String getPricingKey()
      System-wide unique identifier to configure specific pricing for the choice. Relevant if pricing data is managed in a separate system or data store, like the Broadleaf pricing services.
      Returns:
      a unique key to identify this choice, null if there is no external system this should be linked to for pricing data
    • getType

      public String getType()
      Whether or not this item holds a product or a variant that the customer can select from
      Returns:
      the type of this addon item
      See Also:
    • getProduct

      public Product getProduct()
      If the type is DefaultSpecificItemChoiceType.PRODUCT this holds the product for this choice
      Returns:
      the product representing this choice, or null if type is not DefaultSpecificItemChoiceType.PRODUCT
    • getVariant

      public Variant getVariant()
      If the type is DefaultSpecificItemChoiceType.VARIANT this holds the variant for this choice
      Returns:
      the variant representing this choice, or null if type is not DefaultSpecificItemChoiceType.VARIANT
    • getPriceInfo

      public com.broadleafcommerce.pricing.client.domain.PriceInfo getPriceInfo()
      Summary of the pricing information related to the choice. The consumer of this service is expecting this to be the source of truth for the pricing of this specific choice, so this field should be calculated from its own override price if present or be a copy of the underlying product's or variant's pricing to simplify the consumer's logic.
      Specified by:
      getPriceInfo in interface Priceable
      Returns:
      The PriceInfo on the entity.
      See Also:
      • for special pricing considerations
    • getOverridePrice

      public javax.money.MonetaryAmount getOverridePrice()
      The specific price set for this choice that overrides the price of underlying product or variant. This is primarily used for reference in determining whether priceInfo should be disregarded in pricing calculations in this service: If there is an overridePrice, then the priceInfo received from the CatalogProvider should be used as the base for additional pricing calculations informed by the PricingProvider. Otherwise, it should be discarded since it is really a copy of the underlying product or variant and cannot be used as a basis for additional pricing calculations for the SpecificItemChoice itself.
      Returns:
      the price of this choice
    • getVariantPricing

      Pricing overrides if specific variants of the main product this item belongs to are added to the cart. This can be used in a case like a Warranty where the price of the Warranty depends on the price of the item (Variant) selected.
      Returns:
      Pricing overrides if specific variants of the main product are added to the cart.
    • isUsingParentPricing

      public boolean isUsingParentPricing()
      Whether the priceInfo is inherited from the parent ItemChoice. This is usually determined after pricing is hydrated by the PricingProvider.
      Returns:
      Whether the priceInfo is inherited from the parent ItemChoice
    • getAttributes

      public Map<String,Object> getAttributes()
      Map holding any additional attributes passed in the request not matching any defined properties.
    • setPricingKey

      public void setPricingKey(String pricingKey)
      System-wide unique identifier to configure specific pricing for the choice. Relevant if pricing data is managed in a separate system or data store, like the Broadleaf pricing services.
      Parameters:
      pricingKey - a unique key to identify this choice (usually a UUID)
    • setType

      public void setType(String type)
      Whether or not this item holds a product or a variant that the customer can select from
      Parameters:
      type - the type of item this is, usually from DefaultSpecificItemChoiceType
      See Also:
    • setProduct

      public void setProduct(Product product)
      If the type is DefaultSpecificItemChoiceType.PRODUCT this holds the product for this choice
      Parameters:
      product - the product representing this choice
    • setVariant

      public void setVariant(Variant variant)
      If the type is DefaultSpecificItemChoiceType.VARIANT this holds the variant for this choice
      Parameters:
      variant - the variant representing this choice
    • setPriceInfo

      public void setPriceInfo(com.broadleafcommerce.pricing.client.domain.PriceInfo priceInfo)
      Summary of the pricing information related to the choice. The consumer of this service is expecting this to be the source of truth for the pricing of this specific choice, so this field should be calculated from its own override price if present or be a copy of the underlying product's or variant's pricing to simplify the consumer's logic.
      Specified by:
      setPriceInfo in interface Priceable
      Parameters:
      priceInfo - The PriceInfo to set.
      See Also:
      • for special pricing considerations
    • setOverridePrice

      public void setOverridePrice(javax.money.MonetaryAmount overridePrice)
      The specific price set for this choice that overrides the price of underlying product or variant. This is primarily used for reference in determining whether priceInfo should be disregarded in pricing calculations in this service: If there is an overridePrice, then the priceInfo received from the CatalogProvider should be used as the base for additional pricing calculations informed by the PricingProvider. Otherwise, it should be discarded since it is really a copy of the underlying product or variant and cannot be used as a basis for additional pricing calculations for the SpecificItemChoice itself.
      Parameters:
      overridePrice - the price of this choice
    • setVariantPricing

      public void setVariantPricing(Map<String,SpecificItemChoiceVariantPricingOverride> variantPricing)
      Pricing overrides if specific variants of the main product this item belongs to are added to the cart. This can be used in a case like a Warranty where the price of the Warranty depends on the price of the item (Variant) selected.
      Parameters:
      variantPricing - Pricing overrides if specific variants of the main product are added to the cart.
    • setUsingParentPricing

      public void setUsingParentPricing(boolean usingParentPricing)
      Whether the priceInfo is inherited from the parent ItemChoice. This is usually determined after pricing is hydrated by the PricingProvider.
      Parameters:
      usingParentPricing - Whether the priceInfo is inherited from the parent ItemChoice
    • setAttributes

      public void setAttributes(Map<String,Object> attributes)
      Map holding any additional attributes passed in the request not matching any defined properties.
    • 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