org.mentabean.sql.Parametrizable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of menta-bean Show documentation
Show all versions of menta-bean Show documentation
An query helper and simple CRUD ORM.
package org.mentabean.sql;
import java.util.ArrayList;
import java.util.List;
import org.mentabean.sql.param.Param;
public abstract class Parametrizable implements HasParams {
protected List params = new ArrayList();
public abstract String name();
@Override
public Param[] getParams() {
return params.toArray(new Param[0]);
}
protected Parametrizable addParam(Param param) {
params.add(param);
return this;
}
@Override
public String build() {
StringBuilder sb = new StringBuilder(name());
sb.append(" (");
for (Param param : getParams()) {
sb.append(param.paramInQuery()).append(',');
}
sb.setCharAt(sb.length()-1, ')');
return sb.toString();
}
}