EntityDeepJobConfig.java 文件源码

java
阅读 41 收藏 0 点赞 0 评论 0

项目:deep-spark 作者:
@Override
public void validate() {

    if (entityClass == null) {
        throw new IllegalArgumentException("testentity class cannot be null");
    }

    if (!entityClass.isAnnotationPresent(DeepEntity.class)) {
        throw new AnnotationTypeMismatchException(null, entityClass.getCanonicalName());
    }

    super.validate();

    /* let's validate fieldNames in @DeepField annotations */
    Field[] deepFields = AnnotationUtils.filterDeepFields(entityClass);

    Map<String, Cell> colDefs = super.columnDefinitions();

    /* colDefs is null if table does not exist. I.E. this configuration will be used as an output configuration
     object, and the output table is dynamically created */
    if (colDefs == null) {
        return;
    }

    for (Field field : deepFields) {
        String annotationFieldName = AnnotationUtils.deepFieldName(field);

        if (!colDefs.containsKey(annotationFieldName)) {
            throw new DeepNoSuchFieldException("Unknown column name \'" + annotationFieldName + "\' specified for" +
                    " field " + entityClass.getCanonicalName() + "#" + field.getName() + ". Please, " +
                    "make sure the field name you specify in @DeepField annotation matches _exactly_ the column " +
                    "name " +
                    "in the database");
        }
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号