Package org.apache.lucene.util
Class AttributeFactory
- java.lang.Object
-
- org.apache.lucene.util.AttributeFactory
-
- Direct Known Subclasses:
AttributeFactory.DefaultAttributeFactory,AttributeFactory.StaticImplementationAttributeFactory
public abstract class AttributeFactory extends java.lang.ObjectAn AttributeFactory creates instances ofAttributeImpls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classAttributeFactory.DefaultAttributeFactorystatic classAttributeFactory.StaticImplementationAttributeFactory<A extends AttributeImpl>Expert: AttributeFactory returning an instance of the givenclazzfor the attributes it implements.
-
Field Summary
Fields Modifier and Type Field Description static AttributeFactoryDEFAULT_ATTRIBUTE_FACTORYThis is the default factory that createsAttributeImpls using the class name of the suppliedAttributeinterface class by appendingImplto it.private static java.lang.invoke.MethodHandles.Lookuplookupprivate static java.lang.invoke.MethodTypeNO_ARG_CTORprivate static java.lang.invoke.MethodTypeNO_ARG_RETURNING_ATTRIBUTEIMPL
-
Constructor Summary
Constructors Constructor Description AttributeFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract AttributeImplcreateAttributeInstance(java.lang.Class<? extends Attribute> attClass)Returns anAttributeImplfor the suppliedAttributeinterface class.(package private) static java.lang.invoke.MethodHandlefindAttributeImplCtor(java.lang.Class<? extends AttributeImpl> clazz)Returns a correctly typedMethodHandlefor the no-arg ctor of the given class.static <A extends AttributeImpl>
AttributeFactorygetStaticImplementation(AttributeFactory delegate, java.lang.Class<A> clazz)Returns an AttributeFactory returning an instance of the givenclazzfor the attributes it implements.
-
-
-
Field Detail
-
lookup
private static final java.lang.invoke.MethodHandles.Lookup lookup
-
NO_ARG_CTOR
private static final java.lang.invoke.MethodType NO_ARG_CTOR
-
NO_ARG_RETURNING_ATTRIBUTEIMPL
private static final java.lang.invoke.MethodType NO_ARG_RETURNING_ATTRIBUTEIMPL
-
DEFAULT_ATTRIBUTE_FACTORY
public static final AttributeFactory DEFAULT_ATTRIBUTE_FACTORY
This is the default factory that createsAttributeImpls using the class name of the suppliedAttributeinterface class by appendingImplto it.
-
-
Method Detail
-
createAttributeInstance
public abstract AttributeImpl createAttributeInstance(java.lang.Class<? extends Attribute> attClass) throws java.lang.reflect.UndeclaredThrowableException
Returns anAttributeImplfor the suppliedAttributeinterface class.- Throws:
java.lang.reflect.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.
-
findAttributeImplCtor
static final java.lang.invoke.MethodHandle findAttributeImplCtor(java.lang.Class<? extends AttributeImpl> clazz)
Returns a correctly typedMethodHandlefor the no-arg ctor of the given class.
-
getStaticImplementation
public static <A extends AttributeImpl> AttributeFactory getStaticImplementation(AttributeFactory delegate, java.lang.Class<A> clazz)
Returns an AttributeFactory returning an instance of the givenclazzfor the attributes it implements. The givenclazzmust 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 specificAttributeImplwhich 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.
-
-