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

org.hibernate.metamodel.internal.AbstractType Maven / Gradle / Ivy

The 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 .
 */
package org.hibernate.metamodel.internal;

import java.io.Serializable;
import javax.persistence.metamodel.Type;

/**
 * Defines commonality for the JPA {@link Type} hierarchy of interfaces.
 *
 * @author Steve Ebersole
 * @author Brad Koehn
 */
public abstract class AbstractType implements Type, Serializable {
	private final Class javaType;
	private final String typeName;

	/**
	 * Instantiates the type based on the given Java type.
	 *
	 * @param javaType The Java type of the JPA model type.
	 */
	protected AbstractType(Class javaType) {
		this( javaType, javaType != null ? javaType.getName() : null );
	}

	/**
	 * Instantiates the type based on the given Java type.
	 *
	 * @param javaType
	 * @param typeName
	 */
	protected AbstractType(Class javaType, String typeName) {
		this.javaType = javaType;
		this.typeName = typeName == null ? "unknown" : typeName;
	}

	/**
	 * {@inheritDoc}
	 * 

* IMPL NOTE : The Hibernate version may return {@code null} here in the case of either dynamic models or * entity classes mapped multiple times using entity-name. In these cases, the {@link #getTypeName()} value * should be used. */ @Override public Class getJavaType() { return javaType; } /** * Obtains the type name. See notes on {@link #getJavaType()} for details * * @return The type name */ public String getTypeName() { return typeName; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy