cn.schoolwow.util.domain.query.reflection.QueryReflection Maven / Gradle / Ivy
package cn.schoolwow.util.domain.query.reflection;
import cn.schoolwow.util.module.query.reflection.domain.ReflectionOption;
public class QueryReflection {
private ReflectionOption reflectionOption = new ReflectionOption();
/**
* 创建反射查询对象
* */
public static QueryReflection newQuery(Class clazz){
QueryReflection queryReflection = new QueryReflection();
queryReflection.reflectionOption.clazz = clazz;
return queryReflection;
}
public QueryReflection addQuery(String fieldName){
if(null==fieldName||fieldName.isEmpty()){
return this;
}
reflectionOption.filterFieldNames.add(fieldName);
return this;
}
public QueryReflection addQuery(String[] fieldNames){
if(null==fieldNames||fieldNames.length==0){
return this;
}
for(String fieldName:fieldNames){
addQuery(fieldName);
}
return this;
}
public QueryReflection addQuery(FieldFilter fieldFilter){
if(null==fieldFilter){
return this;
}
reflectionOption.fieldFilter = fieldFilter;
return this;
}
public QueryReflectionResponse execute(){
return new QueryReflectionResponse(reflectionOption);
}
}