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

org.hibernate.search.engine.impl.SimpleInitializer 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.engine.impl;

import java.util.Collection;
import java.util.Map;

import org.hibernate.search.backend.spi.Work;
import org.hibernate.search.spi.IndexedTypeIdentifier;
import org.hibernate.search.spi.InstanceInitializer;
import org.hibernate.search.spi.impl.PojoIndexedTypeIdentifier;

/**
 * Simple pass-through implementation of {@code InstanceInitializer}.
 *
 * @author Sanne Grinovero (C) 2011 Red Hat Inc.
 */
public final class SimpleInitializer implements InstanceInitializer {

	public static final SimpleInitializer INSTANCE = new SimpleInitializer();

	private SimpleInitializer() {
		//use INSTANCE as this is stateless
	}

	@Override
	public Object unproxy(Object entity) {
		return entity;
	}

	@Override
	public IndexedTypeIdentifier getIndexedTypeIdFromWork(Work work) {
		return work.getTypeIdentifier() != null ?
				work.getTypeIdentifier() :
				new PojoIndexedTypeIdentifier( getClass( work.getEntity() ) );
	}

	@Override
	@SuppressWarnings( "unchecked" )
	public  Class getClass(T entity) {
		return (Class) entity.getClass();
	}

	@Override
	public  Collection initializeCollection(Collection value) {
		return value;
	}

	@Override
	public  Map initializeMap(Map value) {
		return value;
	}

	@Override
	public Object[] initializeArray(Object[] value) {
		return value;
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy