org.hibernate.engine.config.spi.StandardConverters Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-core Show documentation
Show all versions of hibernate-core Show documentation
The core O/RM functionality as provided by Hibernate
/*
* 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.engine.config.spi;
import static org.hibernate.engine.config.spi.ConfigurationService.Converter;
/**
* Standard set of setting converters
*
* @author Steve Ebersole
*/
public class StandardConverters {
public static final Converter BOOLEAN = new Converter() {
@Override
public Boolean convert(Object value) {
if ( value == null ) {
throw new IllegalArgumentException( "Null value passed to convert" );
}
return Boolean.class.isInstance( value )
? Boolean.class.cast( value )
: Boolean.parseBoolean( value.toString() );
}
};
public static final Converter STRING = new Converter() {
@Override
public String convert(Object value) {
if ( value == null ) {
throw new IllegalArgumentException( "Null value passed to convert" );
}
return value.toString();
}
};
/**
* Disallow direct instantiation
*/
private StandardConverters() {
}
}