org.apache.lucene.util

## Class AttributeFactory

- java.lang.Object
- - org.apache.lucene.util.AttributeFactory

- Direct Known Subclasses:
    AttributeFactory.StaticImplementationAttributeFactory

      public abstract class AttributeFactory
      extends Object

  An AttributeFactory creates instances of `AttributeImpl`s.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `AttributeFactory.StaticImplementationAttributeFactory<A extends AttributeImpl>` Expert: AttributeFactory returning an instance of the given `clazz` for the attributes it implements.

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static AttributeFactory` | `DEFAULT_ATTRIBUTE_FACTORY` This is the default factory that creates `AttributeImpl`s using the class name of the supplied `Attribute` interface class by appending `Impl` to it.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AttributeFactory()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `abstract AttributeImpl` | `createAttributeInstance(Class<? extends Attribute> attClass)` Returns an `AttributeImpl` for the supplied `Attribute` interface class.
    `static <A extends AttributeImpl> AttributeFactory` | `getStaticImplementation(AttributeFactory delegate, Class<A> clazz)` Returns an AttributeFactory returning an instance of the given `clazz` for the attributes it implements.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_ATTRIBUTE_FACTORY

          public static final AttributeFactory DEFAULT_ATTRIBUTE_FACTORY

      This is the default factory that creates `AttributeImpl`s using the class name of the supplied `Attribute` interface class by appending `Impl` to it.

  - ### Constructor Detail

    - #### AttributeFactory

          public AttributeFactory()

  - ### Method Detail

    - #### createAttributeInstance

          public abstract AttributeImpl createAttributeInstance(Class<? extends Attribute> attClass)

      Returns an `AttributeImpl` for the supplied `Attribute` interface class.

    - #### getStaticImplementation

          public static <A extends AttributeImpl> AttributeFactory getStaticImplementation(AttributeFactory delegate,
                                                                                           Class<A> clazz)

      Returns an AttributeFactory returning an instance of the given `clazz` for the attributes it implements. The given `clazz` 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 specific `AttributeImpl` 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`.

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.