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

cn.sylinx.hbatis.ext.parse.ParamMapBuilder Maven / Gradle / Ivy

The newest version!
package cn.sylinx.hbatis.ext.parse;

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

import cn.sylinx.hbatis.kit.StrKit;

/**
 * 参数构建器
 * 
 * @author han
 *
 */
public class ParamMapBuilder {

	private Map map = new HashMap<>();

	public ParamMapBuilder put(String key, Object value) {
		if(value != null) {
			map.put(key, value);
		}
		return this;
	}

	public ParamMapBuilder like(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, "%" + value + "%");
		}
		return this;
	}

	public ParamMapBuilder likeLeft(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, "%" + value);
		}
		return this;
	}

	public ParamMapBuilder likeRight(String key, String value) {
		if (StrKit.isNotBlank(value)) {
			map.put(key, value + "%");
		}
		return this;
	}

	public Map build() {
		return map;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy