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

org.hibernate.resource.beans.spi.ProvidedInstanceManagedBeanImpl Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later
 * See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html
 */
package org.hibernate.resource.beans.spi;

/**
 * ManagedBean implementation for cases where we have been handed an actual
 * instance to use.
 *
 * @author Steve Ebersole
 */
public class ProvidedInstanceManagedBeanImpl implements ManagedBean {
	private final T instance;

	public ProvidedInstanceManagedBeanImpl(T instance) {
		if ( instance == null ) {
			throw new IllegalArgumentException( "Bean instance cannot be null" );
		}

		this.instance = instance;
	}

	@Override
	@SuppressWarnings("unchecked")
	public Class getBeanClass() {
		return (Class) instance.getClass();
	}

	@Override
	public T getBeanInstance() {
		return instance;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy