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:
{@code
- Author:
- Kelly Tisdell (ktisdell), cschneider
- See Also:
IndexableTypes
,Indexable
, Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IndexableType.IndexableTypeConverter
-
Constructor Summary
Constructors Modifier Constructor Description protected
IndexableType(@NonNull String value, boolean translatable, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
Constructs anIndexableType
from a String.protected
IndexableType(@NonNull String value, String label, boolean translatable, boolean vendorBehavior, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
Constructs anIndexableType
from a String with a label.protected
IndexableType(@NonNull String value, String label, boolean translatable, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
Constructs anIndexableType
from a String with a label.protected
IndexableType(@NonNull String value, String label, IndexableType parent, boolean translatable, boolean vendorBehavior, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
Constructs an instance ofIndexableType
with a parent.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canEqual(Object other)
boolean
equals(Object o)
static IndexableType
fromString(String stringValue)
static Collection<IndexableType>
getAllIndexableTypes()
Get all of the existing indexable types.List<com.broadleafcommerce.data.tracking.core.TrackableBehavior>
getBehaviors()
The trackable behaviors which apply to objects of this indexable type.Set<IndexableType>
getChildren()
Returns a set ofIndexableType
instances that have this instance as a parent.static IndexableType
getInstance(String type)
Retrieves an IndexableType based on its String representation.String
getLabel()
The label representation of the indexable type shown for administration.IndexableType
getParent()
Some of these enumerated types can have a parent or common type.IndexableType
getTopLevelAncestor()
Recursively finds the highest level ancestor for thisIndexableType
.com.broadleafcommerce.data.tracking.core.TrackableBehaviorPackage
getTrackableBehaviorPackage()
Produce aTrackableBehaviorPackage
for the behaviors on this indexable type.String
getType()
The named representation of the indexable type.int
hashCode()
boolean
hasTrackableBehavior(com.broadleafcommerce.data.tracking.core.TrackableBehavior trackableBehavior)
Check whether or not objects of this indexable type exhibit the givenTrackableBehavior
.boolean
isTranslatable()
Whether or not objects of this indexable type are translatable.boolean
isVendorBehavior()
Whether or not objects of this indexable type can be discriminated by vendorString
toString()
-
-
-
Constructor Detail
-
IndexableType
protected IndexableType(@NonNull @NonNull String value, boolean translatable, com.broadleafcommerce.data.tracking.core.TrackableBehavior... behaviors)
Constructs anIndexableType
from a String. The convention is to use all capital letters with underscores (_) instead of spaces.- Parameters:
value
- the named representation of the typetranslatable
- whether or not objects of this indexable type are translatablebehaviors
- 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 anIndexableType
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 typetranslatable
- whether or not objects of this indexable type are translatablebehaviors
- 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 anIndexableType
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 typetranslatable
- whether or not objects of this indexable type are translatablevendorBehavior
- whether or not objects of this indexable type can be vendor discriminatedbehaviors
- 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 ofIndexableType
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.IndexableType
s 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 typeparent
- the parent of this typetranslatable
- whether or not objects of this indexable type are translatablevendorBehavior
- whether or not objects of this indexable type can be vendor discriminatedbehaviors
- trackable behaviors which apply to objects of this indexable type
-
-
Method Detail
-
hasTrackableBehavior
public boolean hasTrackableBehavior(com.broadleafcommerce.data.tracking.core.TrackableBehavior trackableBehavior)
Check whether or not objects of this indexable type exhibit the givenTrackableBehavior
.- 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 thisIndexableType
. If thisIndexableType
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 ofIndexableType
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 aTrackableBehaviorPackage
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)
-
canEqual
protected boolean canEqual(Object other)
-
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
-
-