Class IndexableType

java.lang.Object
com.broadleafcommerce.search.api.type.IndexableType
All Implemented Interfaces:
Serializable

public class IndexableType extends Object implements Serializable

Extensible enumeration specifying the type of Indexable being indexed (e.g. PRODUCT, ORDER, CUSTOMER, etc.).


Consumers should extend this class and create public static final members indicating their desired indexable type. A complete example might look like this:

 
     public class ProductIndexableType extends IndexableType {

         public static final IndexableType PRODUCT = new ProductIndexableType("PRODUCT", true);

         protected ProductIndexableType(String value, boolean translatable) {
             super(value, translatable);
         }
     }
 
 

To ensure the IndexableType is initialized properly, additional configuration is required by using the annotation @IndexableTypes on a Spring @Configuration class.

Using the previous example of a ProductIndexableType, the following configuration would be required:

 
     @IndexableTypes({ProductIndexableType.class})
     @Configuration
     public class SpringConfigurationClass {}
 
 
Author:
Kelly Tisdell (ktisdell), cschneider
See Also:
  • Constructor Details

    • IndexableType

      protected IndexableType(@NonNull @NonNull String value, boolean translatable, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
      Constructs an IndexableType from a String. The convention is to use all capital letters with underscores (_) instead of spaces.
      Parameters:
      value - the named representation of the type
      translatable - whether or not objects of this indexable type are translatable
      behaviors - trackable behaviors which apply to objects of this indexable type
    • IndexableType

      protected IndexableType(@NonNull @NonNull String value, @Nullable String label, boolean translatable, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
      Constructs an IndexableType from a String with a label. The convention is to use all capital letters with underscores (_) instead of spaces.
      Parameters:
      value - the named representation of the type
      translatable - whether or not objects of this indexable type are translatable
      behaviors - trackable behaviors which apply to objects of this indexable type
    • IndexableType

      protected IndexableType(@NonNull @NonNull String value, @Nullable String label, boolean translatable, boolean vendorBehavior, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
      Constructs an IndexableType from a String with a label. The convention is to use all capital letters with underscores (_) instead of spaces.
      Parameters:
      value - the named representation of the type
      translatable - whether or not objects of this indexable type are translatable
      vendorBehavior - whether or not objects of this indexable type can be vendor discriminated
      behaviors - trackable behaviors which apply to objects of this indexable type
    • IndexableType

      protected IndexableType(@NonNull @NonNull String value, @Nullable String label, @Nullable IndexableType parent, boolean translatable, boolean vendorBehavior, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
      Constructs an instance of IndexableType with a parent. The parent may be (and often will be) null. Note that a parent must not also have a parent. The parent is meant to simply be a container or marker for other similar types.

      IndexableTypes that have children can be thought of like abstract types in that they typically represent a group of other types.

      For example, imagine that there is a CATALOG type, which could be the parent of PRODUCT and CATEGORY. In this case, PRODUCT and CATEGORY would have a parent of CATALOG, and CATALOG would have no parent. CATALOG would be like an abstract type in that the concrete types are PRODUCT and CATEGORY, for example.

      Parameters:
      value - the named representation of the type
      parent - the parent of this type
      translatable - whether or not objects of this indexable type are translatable
      vendorBehavior - whether or not objects of this indexable type can be vendor discriminated
      behaviors - trackable behaviors which apply to objects of this indexable type
  • Method Details

    • hasTrackableBehavior

      public boolean hasTrackableBehavior(com.broadleafcommerce.data.tracking.core.TrackableBehavior trackableBehavior)
      Check whether or not objects of this indexable type exhibit the given TrackableBehavior.
      Parameters:
      trackableBehavior - the behavior to check for
      Returns:
      whether or not objects of this indexable type exhibit the given behavior
    • getTopLevelAncestor

      @NonNull public IndexableType getTopLevelAncestor()
      Recursively finds the highest level ancestor for this IndexableType. If this IndexableType does not have a parent, then it is the highest level ancestor.
      Returns:
      The highest level ancestor of this type; or this type if it has no ancestors.
    • getChildren

      public final Set<IndexableType> getChildren()
      Returns a set of IndexableType instances that have this instance as a parent. An empty set will be returned if no types have this as a parent.
      Returns:
      the direct children of this type
    • getTrackableBehaviorPackage

      public final com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage getTrackableBehaviorPackage()
      Produce a TrackableBehaviorPackage for the behaviors on this indexable type.
      Returns:
      TrackableBehaviorPackage for the behaviors on this indexable type
    • getInstance

      public static IndexableType getInstance(String type)
      Retrieves an IndexableType based on its String representation.
      Parameters:
      type - The type of this indexable (e.g. PRODUCT, ORDER, CUSTOMER, etc)
      Returns:
      The IndexableType associated with this type.
      Throws:
      IllegalArgumentException - if the IndexableType is not found.
    • getAllIndexableTypes

      public static Collection<IndexableType> getAllIndexableTypes()
      Get all of the existing indexable types.
      Returns:
      all of the existing indexable types
    • fromString

      public static IndexableType fromString(String stringValue)
    • toString

      public String toString()
      Overrides:
      toString in class 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
    • getType

      public String getType()
      The named representation of the indexable type.
      Returns:
      The named representation of the indexable type.
    • getLabel

      public String getLabel()
      The label representation of the indexable type shown for administration.
      Returns:
      The label representation of the indexable type shown for administration.
    • getParent

      @Nullable public IndexableType getParent()
      Some of these enumerated types can have a parent or common type. For example, imagine that there is a CATALOG type, which could be the parent of PRODUCT and CATEGORY. In this case, PRODUCT and CATEGORY would have a parent of CATALOG, and CATALOG would have no parent.
      Returns:
      the parent of this type
    • getBehaviors

      public List<com.broadleafcommerce.data.tracking.core.TrackableBehavior> getBehaviors()
      The trackable behaviors which apply to objects of this indexable type.
      Returns:
      trackable behaviors which apply to objects of this indexable type
    • isTranslatable

      public boolean isTranslatable()
      Whether or not objects of this indexable type are translatable.
      Returns:
      whether or not objects of this indexable type are translatable
    • isVendorBehavior

      public boolean isVendorBehavior()
      Whether or not objects of this indexable type can be discriminated by vendor
      Returns:
      whether or not objects of this indexable type can be discriminated by vendor