This commit is contained in:
@@ -304,7 +304,7 @@ public final class EntityInfo<T> {
|
|||||||
}
|
}
|
||||||
Attribute attr;
|
Attribute attr;
|
||||||
try {
|
try {
|
||||||
attr = Attribute.create(cltmp, field, cryptHandler);
|
attr = Attribute.create(type, cltmp, field, cryptHandler);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -253,6 +253,21 @@ public interface Attribute<T, F> {
|
|||||||
return create(clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, null);
|
return create(clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据一个Class和Field生成 Attribute 对象。
|
||||||
|
*
|
||||||
|
* @param <T> 依附类的类型
|
||||||
|
* @param <F> 字段类型
|
||||||
|
* @param subclass 指定依附的子类
|
||||||
|
* @param clazz 指定依附的类
|
||||||
|
* @param field 字段,如果该字段不存在则抛异常
|
||||||
|
*
|
||||||
|
* @return Attribute对象
|
||||||
|
*/
|
||||||
|
public static <T, F> Attribute<T, F> create(Class<T> subclass, Class<T> clazz, final java.lang.reflect.Field field) {
|
||||||
|
return create(subclass, clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, null);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据一个Class和Field生成 Attribute 对象。
|
* 根据一个Class和Field生成 Attribute 对象。
|
||||||
*
|
*
|
||||||
@@ -268,6 +283,22 @@ public interface Attribute<T, F> {
|
|||||||
return create(clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, attach);
|
return create(clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, attach);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据一个Class和Field生成 Attribute 对象。
|
||||||
|
*
|
||||||
|
* @param <T> 依附类的类型
|
||||||
|
* @param <F> 字段类型
|
||||||
|
* @param subclass 指定依附的子类
|
||||||
|
* @param clazz 指定依附的类
|
||||||
|
* @param field 字段,如果该字段不存在则抛异常
|
||||||
|
* @param attach 附加对象
|
||||||
|
*
|
||||||
|
* @return Attribute对象
|
||||||
|
*/
|
||||||
|
public static <T, F> Attribute<T, F> create(Class<T> subclass, Class<T> clazz, final java.lang.reflect.Field field, Object attach) {
|
||||||
|
return create(subclass, clazz, field.getName(), (Class) null, field, (java.lang.reflect.Method) null, (java.lang.reflect.Method) null, attach);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据一个Class、field别名和Field生成 Attribute 对象。
|
* 根据一个Class、field别名和Field生成 Attribute 对象。
|
||||||
*
|
*
|
||||||
@@ -578,6 +609,28 @@ public interface Attribute<T, F> {
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <T, F> Attribute<T, F> create(final Class<T> clazz, String fieldalias, final Class<F> fieldtype, final java.lang.reflect.Field field, java.lang.reflect.Method getter, java.lang.reflect.Method setter, Object attach) {
|
public static <T, F> Attribute<T, F> create(final Class<T> clazz, String fieldalias, final Class<F> fieldtype, final java.lang.reflect.Field field, java.lang.reflect.Method getter, java.lang.reflect.Method setter, Object attach) {
|
||||||
|
return create(null, clazz, fieldalias, fieldtype, field, getter, setter, attach);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据Class、字段别名、字段类型、Field、getter和setter方法生成 Attribute 对象。 fieldalias/fieldtype、Field、tgetter、setter不能同时为null.
|
||||||
|
*
|
||||||
|
* @param <T> 依附类的类型
|
||||||
|
* @param <F> 字段类型
|
||||||
|
* @param subclass 指定依附的子类
|
||||||
|
* @param clazz 指定依附的类
|
||||||
|
* @param fieldalias 字段别名
|
||||||
|
* @param fieldtype 字段类型
|
||||||
|
* @param field 字段
|
||||||
|
* @param getter getter方法
|
||||||
|
* @param setter setter方法
|
||||||
|
* @param attach 附加对象
|
||||||
|
*
|
||||||
|
* @return Attribute对象
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public static <T, F> Attribute<T, F> create(Class<T> subclass, final Class<T> clazz, String fieldalias, final Class<F> fieldtype, final java.lang.reflect.Field field, java.lang.reflect.Method getter, java.lang.reflect.Method setter, Object attach) {
|
||||||
|
if (subclass == null) subclass = clazz;
|
||||||
if (fieldalias != null && fieldalias.isEmpty()) fieldalias = null;
|
if (fieldalias != null && fieldalias.isEmpty()) fieldalias = null;
|
||||||
int mod = field == null ? java.lang.reflect.Modifier.STATIC : field.getModifiers();
|
int mod = field == null ? java.lang.reflect.Modifier.STATIC : field.getModifiers();
|
||||||
if (field != null && !java.lang.reflect.Modifier.isStatic(mod) && !java.lang.reflect.Modifier.isPublic(mod)) {
|
if (field != null && !java.lang.reflect.Modifier.isStatic(mod) && !java.lang.reflect.Modifier.isPublic(mod)) {
|
||||||
@@ -638,6 +691,8 @@ public interface Attribute<T, F> {
|
|||||||
generictype = tsetter.getGenericParameterTypes()[0];
|
generictype = tsetter.getGenericParameterTypes()[0];
|
||||||
} else if (fieldtype == null) {
|
} else if (fieldtype == null) {
|
||||||
throw new RuntimeException("[" + clazz + "]have no public field or setter or getter");
|
throw new RuntimeException("[" + clazz + "]have no public field or setter or getter");
|
||||||
|
} else if (column == null) {
|
||||||
|
throw new RuntimeException("[" + clazz + "]have no field type");
|
||||||
}
|
}
|
||||||
final Class pcolumn = column;
|
final Class pcolumn = column;
|
||||||
if (column.isPrimitive()) column = java.lang.reflect.Array.get(java.lang.reflect.Array.newInstance(column, 1), 0).getClass();
|
if (column.isPrimitive()) column = java.lang.reflect.Array.get(java.lang.reflect.Array.newInstance(column, 1), 0).getClass();
|
||||||
|
|||||||
Reference in New Issue
Block a user