Class DataDrivenEnum

java.lang.Object
com.broadleafcommerce.catalog.domain.enumeration.DataDrivenEnum
All Implemented Interfaces:
com.broadleafcommerce.data.tracking.core.ContextStateAware, Serializable

public class DataDrivenEnum extends Object implements Serializable, com.broadleafcommerce.data.tracking.core.ContextStateAware
A domain allowing dynamic enum management via the admin. Data driven enums can be mapped to fields of other domains instead of using metadata-based enums, so that enums can be managed dynamically without needing a redeployment.

For example, if the Product domain had a field that only allows certain values while needing to be managed via the admin, such as "material" or "brand", then it would be useful to map data driven enums with different values based on their types.

Author:
Sunny Yu
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    DataDrivenEnum(String id, String type, String value, String displayValue, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected boolean
     
    boolean
     
    com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState
    A subset of Tracking information to expose the context state for this object.
    The display value for the associated type.
    The context ID of this enum.
    Identifies the type of the associated value, this is needed to gather all the enum values based on their types.
    The value of the associated type.
    int
     
    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
    setDisplayValue(String displayValue)
    The display value for the associated type.
    void
    The context ID of this enum.
    void
    Identifies the type of the associated value, this is needed to gather all the enum values based on their types.
    void
    The value of the associated type.
     

    Methods inherited from class java.lang.Object

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

    • DataDrivenEnum

      public DataDrivenEnum()
    • DataDrivenEnum

      public DataDrivenEnum(String id, String type, String value, String displayValue, com.broadleafcommerce.data.tracking.core.filtering.business.domain.ContextState contextState)
  • Method Details

    • getId

      public String getId()
      The context ID of this enum.
      Returns:
      the context ID of this enum
    • getType

      public String getType()
      Identifies the type of the associated value, this is needed to gather all the enum values based on their types.

      For example, if this enum type was to be used for a field representing product's materials, then the type would be "MATERIAL".

      Returns:
      the type for the associated value
    • getValue

      public String getValue()
      The value of the associated type.

      For example, the value for type "MATERIAL" could be "COTTON", "LEATHER", "POLYESTER", etc.

      Returns:
      the value of the associated type
    • getDisplayValue

      public String getDisplayValue()
      The display value for the associated type.

      Different from value, the display value is meant to be more user-friendly and for client-facing usages, such as searching and faceting.

      For example, the display value for type "MATERIAL" could be "Cotton", "Leather", "Polyester", etc.

      Returns:
      the display value of the associated type
    • 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
    • setId

      public void setId(String id)
      The context ID of this enum.
      Parameters:
      id - the context ID of this enum
    • setType

      public void setType(String type)
      Identifies the type of the associated value, this is needed to gather all the enum values based on their types.

      For example, if this enum type was to be used for a field representing product's materials, then the type would be "MATERIAL".

      Parameters:
      type - the type for the associated value
    • setValue

      public void setValue(String value)
      The value of the associated type.

      For example, the value for type "MATERIAL" could be "COTTON", "LEATHER", "POLYESTER", etc.

      Parameters:
      value - the value of the associated type
    • setDisplayValue

      public void setDisplayValue(String displayValue)
      The display value for the associated type.

      Different from value, the display value is meant to be more user-friendly and for client-facing usages, such as searching and faceting.

      For example, the display value for type "MATERIAL" could be "Cotton", "Leather", "Polyester", etc.

      Parameters:
      displayValue - the display value of the associated type
    • 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
    • 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