public BeanInfo(Class<?> clazz){
this.clazz = clazz;
{
MTable annotation = clazz.getAnnotation(MTable.class);
if (annotation == null) {
throw new IllegalArgumentException(clazz.getName() + " not contains @MTable");
}
tableName = annotation.name();
}
for (Field field : clazz.getDeclaredFields()) {
MField annotation = field.getAnnotation(MField.class);
if (annotation == null) {
continue;
}
String columnName = annotation.name();
if (StringUtils.isEmpty(columnName)) {
columnName = field.getName();
}
Field hashFor = null;
String hashForType = null;
if (!StringUtils.isEmpty(annotation.hashFor())) {
try {
hashFor = clazz.getDeclaredField(annotation.hashFor());
hashForType = annotation.hashForType();
} catch (Exception e) {
throw new IllegalStateException("hashFor error", e);
}
}
FieldInfo fieldInfo = new FieldInfo(field, columnName, hashFor, hashForType);
fields.add(fieldInfo);
if (annotation.groupBy()) {
groupByFields.add(fieldInfo);
}
if (hashFor != null) {
hashFields.add(fieldInfo);