本文整理匯總了Java中net.tsz.afinal.annotation.sqlite.Property類的典型用法代碼示例。如果您正苦於以下問題:Java Property類的具體用法?Java Property怎麽用?Java Property使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Property類屬於net.tsz.afinal.annotation.sqlite包,在下文中一共展示了Property類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getColumnByField
import net.tsz.afinal.annotation.sqlite.Property; //導入依賴的package包/類
/**
* 獲取某個屬性對應的 表的列
* @param entity
* @param fieldName
* @return
*/
public static String getColumnByField(Field field){
Property property = field.getAnnotation(Property.class);
if(property != null && property.column().trim().length() != 0){
return property.column();
}
ManyToOne manyToOne = field.getAnnotation(ManyToOne.class);
if(manyToOne!=null && manyToOne.column().trim().length()!=0){
return manyToOne.column();
}
OneToMany oneToMany = field.getAnnotation(OneToMany.class);
if(oneToMany!=null && oneToMany.manyColumn()!=null &&oneToMany.manyColumn().trim().length()!=0){
return oneToMany.manyColumn();
}
Id id = field.getAnnotation(Id.class);
if(id!=null && id.column().trim().length()!=0)
return id.column();
return field.getName();
}
示例2: getFieldByColumnName
import net.tsz.afinal.annotation.sqlite.Property; //導入依賴的package包/類
/**
* 獲取某個字段的值
* @param entity
* @param fieldName
* @return
*/
public static Field getFieldByColumnName(Class<?> clazz,String columnName){
Field field = null;
if(columnName!=null){
Field[] fields = clazz.getDeclaredFields();
if(fields!=null && fields.length>0){
if(columnName.equals(ClassUtils.getPrimaryKeyColumn(clazz)))
field = ClassUtils.getPrimaryKeyField(clazz);
if(field == null){
for(Field f : fields){
Property property = f.getAnnotation(Property.class);
if(property!=null && columnName.equals(property.column())){
field = f;
break;
}
ManyToOne manyToOne = f.getAnnotation(ManyToOne.class);
if(manyToOne!=null && manyToOne.column().trim().length()!=0){
field = f;
break;
}
}
}
if(field == null){
field = getFieldByName(clazz, columnName);
}
}
}
return field;
}
示例3: getPropertyDefaultValue
import net.tsz.afinal.annotation.sqlite.Property; //導入依賴的package包/類
public static String getPropertyDefaultValue(Field field){
Property property = field.getAnnotation(Property.class);
if(property != null && property.defaultValue().trim().length() != 0){
return property.defaultValue();
}
return null ;
}