package foundation.io.object;
|
|
import foundation.util.Util;
|
|
public class Check {
|
|
private boolean required;
|
private boolean dataType;
|
|
public Check(boolean required) {
|
this.required = required;
|
}
|
|
public Check(String checkRule) {
|
initDefault();
|
|
if (Util.isEmpty(checkRule)) {
|
return;
|
}
|
|
checkRule = checkRule.toLowerCase();
|
String[] checks = checkRule.split(";");
|
|
for (String oneCheck : checks) {
|
if (isEmptyCheck(oneCheck)) {
|
this.required = true;
|
}
|
else if(isDataTypeCheck(oneCheck)) {
|
this.dataType = true;
|
}
|
}
|
}
|
|
private boolean isDataTypeCheck(String code) {
|
return code.equals("type");
|
}
|
|
public void initDefault() {
|
this.required = false;
|
this.dataType = false;
|
}
|
|
private boolean isEmptyCheck(String code) {
|
return code.equals("empty");
|
}
|
|
public boolean isRequired() {
|
return required;
|
}
|
|
public boolean dataType() {
|
return dataType;
|
}
|
|
public boolean empty() {
|
return required;
|
}
|
}
|