package com.admios.connector.watsonalchemylanguage.handler;

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

import org.apache.commons.lang3.StringUtils;

import com.ibm.watson.developer_cloud.alchemy.v1.AlchemyLanguage;

public abstract class CommonHandler<T> {

	protected final AlchemyLanguage service;
	private Map<String, Object> params = new HashMap<>();

	public CommonHandler(AlchemyLanguage service, String param, Object value) {
		this.service = service;
		params.put(param, value);
	}

	protected CommonHandler<T> addParam(String param, Object value) {
		if(StringUtils.isEmpty(param)){
			throw new IllegalArgumentException("The param name can be null or empty");
		} else if(value != null){
			params.put(param, value);
		}
		return this;
	}

	protected CommonHandler<T> removeParam(String param) {
		params.remove(param);
		return this;
	}
	
	public Integer parametersSize(){
		return params.size();
	}

	abstract public T execute();
}

@@ -562,16 +562,17 @@
 ) %7B%0A%09%09if
+ 
 (StringU
@@ -682,16 +682,17 @@
  else if
+ 
 (value !
@@ -698,16 +698,17 @@
 != null)
+ 
 %7B%0A%09%09%09par
@@ -885,16 +885,17 @@
 rsSize()
+ 
 %7B%0A%09%09retu

format code.