All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.hibernate.search.analyzer.impl.SimpleLuceneAnalyzerReference Maven / Gradle / Ivy

There is a newer version: 5.11.12.Final
Show newest version
/*
 * 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 org.apache.lucene.analysis.Analyzer;
import org.hibernate.search.util.logging.impl.Log;
import org.hibernate.search.util.logging.impl.LoggerFactory;
import java.lang.invoke.MethodHandles;

/**
 * A reference to an {@link Analyzer}.
 *
 * @author Davide D'Alto
 */
public class SimpleLuceneAnalyzerReference extends LuceneAnalyzerReference {

	private static final Log LOG = LoggerFactory.make( MethodHandles.lookup() );

	private Analyzer analyzer;

	public SimpleLuceneAnalyzerReference(Analyzer analyzer) {
		this.analyzer = analyzer;
	}

	@Override
	public Analyzer getAnalyzer() {
		if ( analyzer == null ) {
			throw LOG.lazyLuceneAnalyzerReferenceNotInitialized( this );
		}
		return analyzer;
	}

	@Override
	public boolean isNormalizer(String fieldName) {
		return false;
	}

	public boolean isInitialized() {
		return true;
	}

	@Override
	public void close() {
		analyzer.close();
	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append( getClass().getSimpleName() );
		sb.append( "<" );
		sb.append( analyzer );
		sb.append( ">" );
		return sb.toString();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy