Class CategoryAttributeImpl
- java.lang.Object
-
- org.apache.lucene.util.AttributeImpl
-
- org.apache.lucene.facet.index.attributes.CategoryAttributeImpl
-
- All Implemented Interfaces:
Serializable,Cloneable,CategoryAttribute,org.apache.lucene.util.Attribute
public final class CategoryAttributeImpl extends org.apache.lucene.util.AttributeImpl implements CategoryAttribute
An implementation ofCategoryAttribute.- See Also:
- Serialized Form
- WARNING: This API is experimental and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description protected CategoryPathcategoryPathThe category path instance.protected HashMap<Class<? extends CategoryProperty>,CategoryProperty>propertiesA map of properties associated to the current category path.
-
Constructor Summary
Constructors Constructor Description CategoryAttributeImpl()Construct an empty CategoryAttributeImpl.CategoryAttributeImpl(CategoryPath categoryPath)Construct a CategoryAttributeImpl with the given CategoryPath.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperty(CategoryProperty property)Add a property.voidclear()Resets this attribute to its initial value: a null category path and no properties.voidclearProperties()Clear all properties.CategoryAttributeclone()Clone thisCategoryAttribute.voidcopyTo(org.apache.lucene.util.AttributeImpl target)booleanequals(Object o)CategoryPathgetCategoryPath()Returns the category path value.CategoryPropertygetProperty(Class<? extends CategoryProperty> propertyClass)Get a property of a certain property class.CategoryPropertygetProperty(Collection<Class<? extends CategoryProperty>> propertyClasses)Get a property of one of given property classes.Set<Class<? extends CategoryProperty>>getPropertyClasses()Get all the active property classes.inthashCode()voidremove(Class<? extends CategoryProperty> propertyClass)Remove an property of a certain property class.voidset(CategoryAttribute other)Set the content of thisCategoryAttributefrom anotherCategoryAttributeobject.voidsetCategoryPath(CategoryPath cp)Sets the category path value of this attribute.
-
-
-
Field Detail
-
categoryPath
protected CategoryPath categoryPath
The category path instance.
-
properties
protected HashMap<Class<? extends CategoryProperty>,CategoryProperty> properties
A map of properties associated to the current category path.
-
-
Constructor Detail
-
CategoryAttributeImpl
public CategoryAttributeImpl()
Construct an empty CategoryAttributeImpl.
-
CategoryAttributeImpl
public CategoryAttributeImpl(CategoryPath categoryPath)
Construct a CategoryAttributeImpl with the given CategoryPath.- Parameters:
categoryPath- The category path to use.
-
-
Method Detail
-
set
public void set(CategoryAttribute other)
Description copied from interface:CategoryAttributeSet the content of thisCategoryAttributefrom anotherCategoryAttributeobject.- Specified by:
setin interfaceCategoryAttribute- Parameters:
other- TheCategoryAttributeto take the content from.
-
getCategoryPath
public CategoryPath getCategoryPath()
Returns the category path value.- Specified by:
getCategoryPathin interfaceCategoryAttribute- Returns:
- The category path last assigned to this attribute, or null if none has been assigned.
-
setCategoryPath
public void setCategoryPath(CategoryPath cp)
Description copied from interface:CategoryAttributeSets the category path value of this attribute.- Specified by:
setCategoryPathin interfaceCategoryAttribute- Parameters:
cp- A category path. May not be null.
-
addProperty
public void addProperty(CategoryProperty property) throws UnsupportedOperationException
Description copied from interface:CategoryAttributeAdd a property. The property can be later retrieved usingCategoryAttribute.getProperty(Class)with this property class .
Adding multiple properties of the same class is forbidden.- Specified by:
addPropertyin interfaceCategoryAttribute- Parameters:
property- The property to add.- Throws:
UnsupportedOperationException- When attempting to add a property of a class that was added before and merge is prohibited.
-
getProperty
public CategoryProperty getProperty(Class<? extends CategoryProperty> propertyClass)
Description copied from interface:CategoryAttributeGet a property of a certain property class.- Specified by:
getPropertyin interfaceCategoryAttribute- Parameters:
propertyClass- The required property class.- Returns:
- The property of the given class, or null if no such property exists.
-
getProperty
public CategoryProperty getProperty(Collection<Class<? extends CategoryProperty>> propertyClasses)
Description copied from interface:CategoryAttributeGet a property of one of given property classes.- Specified by:
getPropertyin interfaceCategoryAttribute- Parameters:
propertyClasses- The property classes.- Returns:
- A property matching one of the given classes, or null if no such property exists.
-
copyTo
public void copyTo(org.apache.lucene.util.AttributeImpl target)
- Specified by:
copyToin classorg.apache.lucene.util.AttributeImpl
-
clone
public CategoryAttribute clone()
Description copied from interface:CategoryAttributeClone thisCategoryAttribute.- Specified by:
clonein interfaceCategoryAttribute- Overrides:
clonein classorg.apache.lucene.util.AttributeImpl- Returns:
- A clone of this
CategoryAttribute.
-
clear
public void clear()
Description copied from interface:CategoryAttributeResets this attribute to its initial value: a null category path and no properties.- Specified by:
clearin interfaceCategoryAttribute- Specified by:
clearin classorg.apache.lucene.util.AttributeImpl
-
clearProperties
public void clearProperties()
Description copied from interface:CategoryAttributeClear all properties.- Specified by:
clearPropertiesin interfaceCategoryAttribute
-
getPropertyClasses
public Set<Class<? extends CategoryProperty>> getPropertyClasses()
Description copied from interface:CategoryAttributeGet all the active property classes.- Specified by:
getPropertyClassesin interfaceCategoryAttribute- Returns:
- A set containing the active property classes, or
nullif there are no properties.
-
remove
public void remove(Class<? extends CategoryProperty> propertyClass)
Description copied from interface:CategoryAttributeRemove an property of a certain property class.- Specified by:
removein interfaceCategoryAttribute- Parameters:
propertyClass- The required property class.
-
-