Class CustomerSegmentType

java.lang.Object
com.broadleafcommerce.customer.segments.CustomerSegmentType
All Implemented Interfaces:
Serializable

public class CustomerSegmentType extends Object implements Serializable
Extensible enumeration defining customer segment types. (e.g. RULE_BASED, CUSTOMER_SET)

Consumers wishing to add additional CustomerSegment types should extend this class with an implementation similar to the following:

 {
     @code
     public class CustomerSetSegmentType extends CustomerSegmentType {

         public static final CustomerSegmentType CUSTOMER_SET =
                 new CustomerSetSegmentType("CUSTOMER_SET", true);

         protected CustomerSetSegmentType(String type, boolean includeCustomers) {
             super(type, includeCustomers);
         }
     }
 }
 

For proper initialization, configuration is required. For example, to configure the type defined above, we would add the annotation CustomerSegmentTypes to a Spring @Configuration class as such:

 {
     @code
     @CustomerSegmentTypes({CustomerSetSegmentType.class})
     @Configuration
     public class SpringConfigurationClass {}
 }
 
See Also:
  • Field Details

    • RULE_BASED

      public static final CustomerSegmentType RULE_BASED
      A segment where membership is determined by a rule. This rule may be evaluated offline in a batch process against known registered customers in the data store or in real-time against request and auth data.
      See Also:
    • CUSTOMER_SET

      public static final CustomerSegmentType CUSTOMER_SET
      A segment with a manually curated set of customers.
    • EXTERNAL

      public static final CustomerSegmentType EXTERNAL
      A segment that is a reference to a segment defined in an external system.
  • Constructor Details

    • CustomerSegmentType

      protected CustomerSegmentType(@NonNull @NonNull String type, boolean manuallyAddCustomers)
      Constructs a CustomerSegmentType. The convention is to use all capital letters with spaces represented as underscores (_)

      manuallyAddCustomers indicates whether or not individual customers may be added to this segment type. Attempts to add a customer to, say, a rule based segment are likely a mistake in logic.

      Parameters:
      type - the type of this customer segment
      manuallyAddCustomers - Can individual customers be manually added to this segment type?
  • Method Details

    • getType

      public final String getType()
      Returns:
      The String representation of this segment type.
    • canManuallyAddCustomers

      public final boolean canManuallyAddCustomers()
      Returns:
      Can individual customers be added to this segment type?
    • getInstance

      public static CustomerSegmentType getInstance(String type)
      Returns an instance of a customer segment based on its String type.
      Parameters:
      type - The type of this Customer Segment
    • getAllIndexableTypes

      public static Collection<CustomerSegmentType> getAllIndexableTypes()
      Retrieve all registered customer segment types.
    • fromString

      public static CustomerSegmentType fromString(String stringValue)
    • isRuleBased

      public static boolean isRuleBased(String customerSegmentType)
    • isCustomerSet

      public static boolean isCustomerSet(String customerSegmentType)
    • isExternal

      public static boolean isExternal(String customerSegmentType)
    • 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