getAttribute

fun <T : Attribute> getAttribute(attClass: KClass<T>): T?

Returns the instance of the passed in Attribute contained in this AttributeSource

The caller must pass in a Class value.

Return

instance of the passed in Attribute, or null if this AttributeSource does not contain the Attribute. It is recommended to always use .addAttribute even in consumers of TokenStreams, because you cannot know if a specific TokenStream really uses a specific Attribute. .addAttribute will automatically make the attribute available. If you want to only use the attribute, if it is available (to optimize consuming), use .hasAttribute.