package com.ffii.core.utils;

import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.ServletRequestBindingException;

/**
 * ArgsBuilder of Criteria
 * 
 * @see {@link CriteriaUtils}
 * @author fung
 */
public class CriteriaArgsBuilder {

    private Map<String, Object> args;
    private HttpServletRequest request;

    public CriteriaArgsBuilder(HttpServletRequest request) {
        args = new HashMap<String, Object>();
        this.request = request;
    }

    public CriteriaArgsBuilder(HttpServletRequest request, Map<String, Object> args) {
        this.args = args;
        this.request = request;
    }

    public CriteriaArgsBuilder addStringExact(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringExact(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringLike(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringLike(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addString(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addString(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringContains(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringContains(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringStartsWith(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringStartsWith(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringEndsWith(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringEndsWith(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringList(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringList(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addStringCsv(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addStringCsv(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addInteger(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addInteger(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addNonZeroInteger(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addNonZeroInteger(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addIntegerList(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addIntegerList(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addNonZeroIntegerList(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addNonZeroIntegerList(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addLong(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addLong(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addNonZeroLong(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addNonZeroLong(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addDate(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addDate(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addDateTo(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addDateTo(request, args, paramName);
        return this;
    }

    public CriteriaArgsBuilder addBoolean(String paramName) throws ServletRequestBindingException {
        CriteriaUtils.addBoolean(request, args, paramName);
        return this;
    }

    public Map<String, Object> toMap() {
        return this.args;
    }
}