com.hframework.beans.class0.Constructor Maven / Gradle / Ivy
package com.hframework.beans.class0;
import java.util.ArrayList;
import java.util.List;
public class Constructor {
private List parameterList =new ArrayList();
private List codelnList = new ArrayList();
private String parameterStr = null;
private boolean flag = false;
public Constructor() {
super();
}
public Constructor(List parameterList) {
super();
this.parameterList = parameterList;
for (Field field : parameterList) {
codelnList.add("this." + field.getName() + " = " + field.getName() + ";");
}
getParameterStr();
}
public void addParameters(List fields) {
parameterList.addAll(fields);
parameterList.clear();
for (Field field : parameterList) {
codelnList.add("this." + field.getName() + " = " + field.getName() + ";");
}
getParameterStr();
}
public void addCodeLn(String codeLn) {
if(!flag) {
codelnList.clear();
flag = true;
}
codelnList.add(codeLn);
}
public void addParameter(Field field) {
parameterList.add(field);
getParameterStr();
}
public List getParameterList() {
return parameterList;
}
public void setParameterList(List parameterList) {
this.parameterList = parameterList;
}
public String getParameterStr() {
parameterStr = null;
if(parameterList != null) {
for (Field field : parameterList) {
if(parameterStr == null) {
parameterStr = field.getType() + " " + field.getName();
}else {
parameterStr += (", " + field.getType() + " " + field.getName());
}
}
}
return parameterStr;
}
public List getCodelnList() {
return codelnList;
}
public void setCodelnList(List codelnList) {
this.codelnList = codelnList;
}
}