/**
* Adds an extended property to the BeanMapping.
*
* @param props
* @param name
* @param type
* @param columnMapping
* @return
*/
public static <B> Property<B, Object> initExtendedProperty(Map<String, Property<B, Object>> props, String name, Class<B> type, String columnMapping) {
PropertyDescriptor pd = BeanMappingReflectionUtils.getPropertyDescriptor(type, name);
if (!isPropertyReadableAndWritable(pd)) {
return null;
}
List<Annotation> ans = BeanMappingReflectionUtils.readAnnotations(type, pd.getName());
Column column = BeanMappingReflectionUtils.getAnnotation(ans, Column.class);
ReflectionProperty<B, Object> prop = new ReflectionProperty<B, Object>(name,
(Class<Object>) pd.getPropertyType(), inferColumn(columnMapping != null ? columnMapping : name, column), pd.getWriteMethod(),
pd.getReadMethod());
if (column != null) {
prop.readOnly(true);
}
if (BeanMappingReflectionUtils.getAnnotation(ans, Id.class) != null) {
prop.setIdProperty(true);
}
if (useAdditionalConfiguration()) {
prop.getConfiguration().setAnnotations(ans);
if (Collection.class.isAssignableFrom(pd.getPropertyType())) {
prop.getConfiguration().setCollectionTypeArguments(
((ParameterizedType) pd.getReadMethod().getGenericReturnType()).getActualTypeArguments());
}
}
if (BeanMappingReflectionUtils.getAnnotation(ans, Embedded.class) != null) {
props.putAll(getCompositeProperties(prop, ans));
} else {
props.put(prop.name(), prop);
}
return prop;
}
BeanMappingUtils.java 文件源码
java
阅读 41
收藏 0
点赞 0
评论 0
项目:petit
作者:
评论列表
文章目录