Package org.apache.lucene.util
Class AttributeFactory
java.lang.Object
org.apache.lucene.util.AttributeFactory
- Direct Known Subclasses:
AttributeFactory.StaticImplementationAttributeFactory
An AttributeFactory creates instances of
AttributeImpl
s.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Expert: AttributeFactory returning an instance of the givenclazz
for the attributes it implements. -
Field Summary
Modifier and TypeFieldDescriptionstatic final AttributeFactory
This is the default factory that createsAttributeImpl
s using the class name of the suppliedAttribute
interface class by appendingImpl
to it. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract AttributeImpl
createAttributeInstance
(Class<? extends Attribute> attClass) Returns anAttributeImpl
for the suppliedAttribute
interface class.static <A extends AttributeImpl>
AttributeFactorygetStaticImplementation
(AttributeFactory delegate, Class<A> clazz) Returns an AttributeFactory returning an instance of the givenclazz
for the attributes it implements.
-
Field Details
-
DEFAULT_ATTRIBUTE_FACTORY
This is the default factory that createsAttributeImpl
s using the class name of the suppliedAttribute
interface class by appendingImpl
to it.
-
-
Constructor Details
-
AttributeFactory
public AttributeFactory()
-
-
Method Details
-
createAttributeInstance
public abstract AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass) throws UndeclaredThrowableException Returns anAttributeImpl
for the suppliedAttribute
interface class.- Throws:
UndeclaredThrowableException
- A wrapper runtime exception thrown if the constructor of the attribute class throws a checked exception. Note that attributes should not throw or declare checked exceptions; this may be verified and fail early in the future.
-
getStaticImplementation
public static <A extends AttributeImpl> AttributeFactory getStaticImplementation(AttributeFactory delegate, Class<A> clazz) Returns an AttributeFactory returning an instance of the givenclazz
for the attributes it implements. The givenclazz
must have a public no-arg constructor. For all other attributes it calls the given delegate factory as fallback. This method can be used to prefer a specificAttributeImpl
which combines multiple attributes over separate classes.Please save instances created by this method in a static final field, because on each call, this does reflection for creating a
MethodHandle
.
-