cn.featherfly.conversion.string.bp.BeanPropertyArrayFormatConvertor Maven / Gradle / Ivy
package cn.featherfly.conversion.string.bp;
import cn.featherfly.common.bean.BeanProperty;
import cn.featherfly.common.lang.ArrayUtils;
import cn.featherfly.conversion.annotation.Format;
import cn.featherfly.conversion.string.basic.ArrayConvertor;
import cn.featherfly.conversion.string.format.FormatConvertor;
import cn.featherfly.conversion.string.format.FormatType;
/**
*
* 数组转换器
*
*
* @param
* 数组自身类型
* @param
* 数组项类型
* @author 钟冀
*/
public abstract class BeanPropertyArrayFormatConvertor extends
ArrayConvertor, E, FormatType> {
/**
* @param convertor
* conversion
*/
public BeanPropertyArrayFormatConvertor(FormatConvertor convertor) {
super(convertor);
}
/**
* {@inheritDoc}
*/
@Override
protected FormatType getArrayItemGenericType(BeanProperty beanProperty) {
Format format = beanProperty.getAnnotation(Format.class);
FormatType ft = new FormatType<>(getConvertor().getSourceType());
ft.setFormat(format.format());
ft.setFormats(ArrayUtils.toList(format.formats()));
return ft;
}
}