All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.schoolwow.util.domain.query.reflection.QueryReflection Maven / Gradle / Ivy

There is a newer version: 1.0.2
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy