romseygeek commented on a change in pull request #357: [SOLR-12238] Synonym Queries boost by payload URL: https://github.com/apache/lucene-solr/pull/357#discussion_r374012699
########## File path: lucene/core/src/java/org/apache/lucene/util/AttributeSource.java ########## @@ -171,6 +171,23 @@ public boolean hasNext() { return implInterfaces.get(clazz); } + /** + * Returns the instance of the passed in AttributeImpl contained in this AttributeSource + * <p> + * The caller must pass in a Class<? extends AttributeImpl> value. + * + * @return instance of the passed in AttributeImpl, or {@code null} if this AttributeSource + * does not contain the AttributeImpl. It is recommended to always use + * {@link #addAttributeImpl} even in consumers of TokenStreams, because you cannot + * know if a specific TokenStream really uses a specific AttributeImpl. + * {@link #addAttributeImpl} will automatically make the attribute impl available. + * If you want to only use the attribute , if it is available (to optimize + * consuming), use {@link #hasAttribute}. + */ + public final <T extends AttributeImpl> T getAttributeImpl(Class<T> attClass) { + return attClass.cast(attributeImpls.get(attClass)); + } + Review comment: This shouldn't be necessary, we use interfaces everywhere else? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org