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

org.hibernate.EntityMode 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 .
 */
package org.hibernate;

import java.util.Locale;

/**
 * Defines the representation modes available for entities.
 *
 * @author Steve Ebersole
 */
public enum EntityMode {
	/**
	 * The {@code pojo} entity mode describes an entity model made up of entity classes (loosely) following
	 * the java bean convention.
	 */
	POJO( "pojo" ),

	/**
	 * The {@code dynamic-map} entity mode describes an entity model defined using {@link java.util.Map} references.
	 */
	MAP( "dynamic-map" );

	private final String externalName;

	private EntityMode(String externalName) {
		this.externalName = externalName;
	}

	public String getExternalName() {
		return externalName;
	}

	@Override
	public String toString() {
		return externalName;
	}

	/**
	 * Legacy-style entity-mode name parsing.  Case insensitive
	 *
	 * @param entityMode The entity mode name to evaluate
	 *
	 * @return The appropriate entity mode; {@code null} for incoming {@code entityMode} param is treated by returning
	 * {@link #POJO}.
	 */
	public static EntityMode parse(String entityMode) {
		if ( entityMode == null ) {
			return POJO;
		}
		if ( MAP.externalName.equalsIgnoreCase( entityMode ) ) {
			return MAP;
		}
		return valueOf( entityMode.toUpperCase( Locale.ENGLISH ) );
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy