package com.lightinit.hsdatashow.annotation;

/**
 * @author WangYao
 * @date 2018/6/1 15:39
 * @description 字段描述器帮助类
 */
public class FieldDescriberHelper {

    public static <T> FieldDescriber getFieldDescriber(Class clazz, String fieldName){
        return AnnotationHelper.getFieldAnnotation(clazz, fieldName, FieldDescriber.class);
    }

    public static <T> FieldDescriber getFieldDescriber(T object, String fieldName){
        return AnnotationHelper.getFieldAnnotation(object, fieldName, FieldDescriber.class);
    }

    public static <T> String getFieldDescription(Class clazz, String fieldName){
        FieldDescriber fieldDescriber = getFieldDescriber(clazz, fieldName);
        return fieldDescriber == null ? null : fieldDescriber.descripton();
    }

    public static <T> String getFieldDescription(T object, String fieldName){
        FieldDescriber fieldDescriber = getFieldDescriber(object, fieldName);
        return fieldDescriber == null ? null : fieldDescriber.descripton();
    }
}
