remove two unused classes
This commit is contained in:
parent
af8f2da6f2
commit
69091d1394
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.metamodel.model.convert.spi;
|
|
||||||
|
|
||||||
import org.hibernate.SessionFactory;
|
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|
||||||
import org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl;
|
|
||||||
import org.hibernate.resource.beans.spi.ManagedBean;
|
|
||||||
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
|
||||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
|
||||||
import org.hibernate.type.spi.TypeConfiguration;
|
|
||||||
|
|
||||||
import jakarta.persistence.AttributeConverter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Factory for converter instances
|
|
||||||
*
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class Converters {
|
|
||||||
/**
|
|
||||||
* Generates a BasicValueConverter based on an {@link AttributeConverter}
|
|
||||||
*/
|
|
||||||
public static <O,R> BasicValueConverter<O,R> jpaAttributeConverter(
|
|
||||||
JavaType<R> relationalJtd,
|
|
||||||
JavaType<O> domainJtd,
|
|
||||||
Class<? extends AttributeConverter<O,R>> converterClass,
|
|
||||||
SessionFactory factory) {
|
|
||||||
final SessionFactoryImplementor sfi = (SessionFactoryImplementor) factory;
|
|
||||||
|
|
||||||
final ManagedBeanRegistry beanRegistry = sfi.getServiceRegistry().getService( ManagedBeanRegistry.class );
|
|
||||||
final ManagedBean<? extends AttributeConverter<O, R>> converterBean = beanRegistry.getBean( converterClass );
|
|
||||||
|
|
||||||
final TypeConfiguration typeConfiguration = sfi.getTypeConfiguration();
|
|
||||||
final JavaTypeRegistry jtdRegistry = typeConfiguration.getJavaTypeRegistry();
|
|
||||||
final JavaType<? extends AttributeConverter<O, R>> converterJtd = jtdRegistry.getDescriptor( converterClass );
|
|
||||||
|
|
||||||
return new JpaAttributeConverterImpl<>( converterBean, converterJtd, domainJtd, relationalJtd );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Converters() {
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,53 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.metamodel.model.convert.spi;
|
|
||||||
|
|
||||||
import java.util.function.Function;
|
|
||||||
|
|
||||||
import org.hibernate.type.descriptor.java.JavaType;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Steve Ebersole
|
|
||||||
*/
|
|
||||||
public class SimpleBasicValueConverter<D,R> implements BasicValueConverter<D,R> {
|
|
||||||
private final JavaType<D> domainJtd;
|
|
||||||
private final JavaType<R> relationalJtd;
|
|
||||||
|
|
||||||
private final Function<R,D> toDomainHandler;
|
|
||||||
private final Function<D,R> toRelationalHandler;
|
|
||||||
|
|
||||||
public SimpleBasicValueConverter(
|
|
||||||
JavaType<D> domainJtd,
|
|
||||||
JavaType<R> relationalJtd,
|
|
||||||
Function<R,D> toDomainHandler,
|
|
||||||
Function<D,R> toRelationalHandler) {
|
|
||||||
this.domainJtd = domainJtd;
|
|
||||||
this.relationalJtd = relationalJtd;
|
|
||||||
this.toDomainHandler = toDomainHandler;
|
|
||||||
this.toRelationalHandler = toRelationalHandler;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public D toDomainValue(R relationalForm) {
|
|
||||||
return toDomainHandler.apply( relationalForm );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public R toRelationalValue(D domainForm) {
|
|
||||||
return toRelationalHandler.apply( domainForm );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaType<D> getDomainJavaType() {
|
|
||||||
return domainJtd;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public JavaType<R> getRelationalJavaType() {
|
|
||||||
return relationalJtd;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue