org.hibernate.search.analyzer.impl.LuceneAnalyzerReference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-search-engine Show documentation
Show all versions of hibernate-search-engine Show documentation
Core of the Object/Lucene mapper, query engine and index management
/*
* Hibernate Search, full-text search for your domain model
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.search.analyzer.impl;
import java.lang.invoke.MethodHandles;
import org.apache.lucene.analysis.Analyzer;
import org.hibernate.search.analyzer.spi.AnalyzerReference;
import org.hibernate.search.util.logging.impl.Log;
import org.hibernate.search.util.logging.impl.LoggerFactory;
/**
* A reference to an {@link Analyzer}.
*
* @author Davide D'Alto
*/
public abstract class LuceneAnalyzerReference implements AnalyzerReference {
private final Log log = LoggerFactory.make( MethodHandles.lookup() );
public abstract Analyzer getAnalyzer();
@Override
public boolean is(Class analyzerType) {
return analyzerType.isAssignableFrom( getClass() );
}
@Override
public T unwrap(Class analyzerType) {
try {
return analyzerType.cast( this );
}
catch (ClassCastException e) {
if ( !LuceneAnalyzerReference.class.isAssignableFrom( analyzerType ) ) {
// Not even the same technology, probably a user error
throw log.invalidConversionFromLuceneAnalyzer( this, e );
}
else {
// The other type uses the same technology... probably a bug?
throw e;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy