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

gu.sql2java.ColumnCodec Maven / Gradle / Ivy

There is a newer version: 5.2.0
Show newest version
package gu.sql2java;

import java.lang.reflect.Type;

import gu.sql2java.exception.ResultSetCodecException;

/**
 * 数据库字段编解码器
 * @author guyadong
 * @since 3.21.0
 */
public interface ColumnCodec {
	/**
	 * 将数据库中获取的结果集({@link java.sql.ResultSet})的字段值反序列化为指定的类型
	 * @param  目标类型
	 * @param columnValue 字段值,为{@code null}返回{@code null}
	 * @param targetType 反序列化目标类型,对于不支持的目标类型抛出异常{@link gu.sql2java.exception.UnsupportTypeException}
	 * @throws ResultSetCodecException 
	 */
	public T deserialize(Object columnValue,Class targetType) throws ResultSetCodecException;
	/**
	 * 将数据库中获取的结果集({@link java.sql.ResultSet})的字段值反序列化为指定的类型
	 * @param  目标类型
	 * @param columnValue 字段值,为{@code null}返回{@code null}
	 * @param targetType 反序列化目标类型,对于不支持的目标类型抛出异常{@link gu.sql2java.exception.UnsupportTypeException}
	 * @throws ResultSetCodecException 
	 */
	public  T deserialize(Object columnValue, Type targetType) throws ResultSetCodecException;
	/**
	 * 将指定的对象序列化为数据库存储类型
	 * @param  输入类型
	 * @param obj 序列化对象,为{@code null}返回{@code null}
	 * @param targetType 序列化目标类型,对于不支持的目标类型抛出异常{@link gu.sql2java.exception.UnsupportTypeException}
	 * @throws ResultSetCodecException 
	 */
	public T serialize(Object obj, Class targetType) throws ResultSetCodecException;
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy