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 CategoryPath
categoryPath
The category path instance.protected HashMap<Class<? extends CategoryProperty>,CategoryProperty>
properties
A 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 void
addProperty(CategoryProperty property)
Add a property.void
clear()
Resets this attribute to its initial value: a null category path and no properties.void
clearProperties()
Clear all properties.CategoryAttribute
clone()
Clone thisCategoryAttribute
.void
copyTo(org.apache.lucene.util.AttributeImpl target)
boolean
equals(Object o)
CategoryPath
getCategoryPath()
Returns the category path value.CategoryProperty
getProperty(Class<? extends CategoryProperty> propertyClass)
Get a property of a certain property class.CategoryProperty
getProperty(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.int
hashCode()
void
remove(Class<? extends CategoryProperty> propertyClass)
Remove an property of a certain property class.void
set(CategoryAttribute other)
Set the content of thisCategoryAttribute
from anotherCategoryAttribute
object.void
setCategoryPath(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:CategoryAttribute
Set the content of thisCategoryAttribute
from anotherCategoryAttribute
object.- Specified by:
set
in interfaceCategoryAttribute
- Parameters:
other
- TheCategoryAttribute
to take the content from.
-
getCategoryPath
public CategoryPath getCategoryPath()
Returns the category path value.- Specified by:
getCategoryPath
in 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:CategoryAttribute
Sets the category path value of this attribute.- Specified by:
setCategoryPath
in interfaceCategoryAttribute
- Parameters:
cp
- A category path. May not be null.
-
addProperty
public void addProperty(CategoryProperty property) throws UnsupportedOperationException
Description copied from interface:CategoryAttribute
Add 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:
addProperty
in 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:CategoryAttribute
Get a property of a certain property class.- Specified by:
getProperty
in 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:CategoryAttribute
Get a property of one of given property classes.- Specified by:
getProperty
in 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:
copyTo
in classorg.apache.lucene.util.AttributeImpl
-
clone
public CategoryAttribute clone()
Description copied from interface:CategoryAttribute
Clone thisCategoryAttribute
.- Specified by:
clone
in interfaceCategoryAttribute
- Overrides:
clone
in classorg.apache.lucene.util.AttributeImpl
- Returns:
- A clone of this
CategoryAttribute
.
-
clear
public void clear()
Description copied from interface:CategoryAttribute
Resets this attribute to its initial value: a null category path and no properties.- Specified by:
clear
in interfaceCategoryAttribute
- Specified by:
clear
in classorg.apache.lucene.util.AttributeImpl
-
clearProperties
public void clearProperties()
Description copied from interface:CategoryAttribute
Clear all properties.- Specified by:
clearProperties
in interfaceCategoryAttribute
-
getPropertyClasses
public Set<Class<? extends CategoryProperty>> getPropertyClasses()
Description copied from interface:CategoryAttribute
Get all the active property classes.- Specified by:
getPropertyClasses
in interfaceCategoryAttribute
- Returns:
- A set containing the active property classes, or
null
if there are no properties.
-
remove
public void remove(Class<? extends CategoryProperty> propertyClass)
Description copied from interface:CategoryAttribute
Remove an property of a certain property class.- Specified by:
remove
in interfaceCategoryAttribute
- Parameters:
propertyClass
- The required property class.
-
-