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

org.mentabean.sql.param.ParamFunction Maven / Gradle / Ivy

There is a newer version: 2.2.4
Show newest version
package org.mentabean.sql.param;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.mentabean.sql.Function;

public class ParamFunction implements Param {

	private Function function;
	
	public ParamFunction(Function function) {
		this.function = function;
	}
	
	@Override
	public String paramInQuery() {
		return function.build();
	}

	@Override
	public Object[] values() {
		
		List values = new ArrayList();
		
		Param[] params = function.getParams();
		
		if (params != null && params.length > 0) {
			for (Param p : params) {
				if (p.values() != null && p.values().length > 0) {
					values.addAll(Arrays.asList(p.values()));
				}
			}
		}
		
		return values.toArray();
	}

}