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

org.hibernate.property.access.spi.BuiltInPropertyAccessStrategies Maven / Gradle / Ivy

There is a newer version: 6.5.0.CR2
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.property.access.spi;

import org.hibernate.property.access.internal.PropertyAccessStrategyBasicImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyEmbeddedImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyFieldImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyMapImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyMixedImpl;
import org.hibernate.property.access.internal.PropertyAccessStrategyNoopImpl;

/**
 * Describes the built-in externally-nameable PropertyAccessStrategy implementations.
 *
 * @author Steve Ebersole
 */
public enum BuiltInPropertyAccessStrategies {
	BASIC( "property", PropertyAccessStrategyBasicImpl.INSTANCE ),
	FIELD( "field", PropertyAccessStrategyFieldImpl.INSTANCE ),
	MIXED( "mixed", PropertyAccessStrategyMixedImpl.INSTANCE ),
	MAP( "map", PropertyAccessStrategyMapImpl.INSTANCE ),
	EMBEDDED( "embedded", PropertyAccessStrategyEmbeddedImpl.INSTANCE ),
	NOOP( "noop", PropertyAccessStrategyNoopImpl.INSTANCE )
	;

	private final String externalName;
	private final PropertyAccessStrategy strategy;

	BuiltInPropertyAccessStrategies(String externalName, PropertyAccessStrategy strategy) {
		this.externalName = externalName;
		this.strategy = strategy;
	}

	public String getExternalName() {
		return externalName;
	}

	public PropertyAccessStrategy getStrategy() {
		return strategy;
	}

	public static BuiltInPropertyAccessStrategies interpret(String name) {
		if ( BASIC.externalName.equals( name ) ) {
			return BASIC;
		}
		else if ( FIELD.externalName.equals( name ) ) {
			return FIELD;
		}
		else if ( MAP.externalName.equals( name ) ) {
			return MAP;
		}
		else if ( EMBEDDED.externalName.equals( name ) ) {
			return EMBEDDED;
		}
		else if ( NOOP.externalName.equals( name ) ) {
			return NOOP;
		}

		return null;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy