cn.ipokerface.common.validation.validator.NotEmptyConstraintValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of common-beans Show documentation
Show all versions of common-beans Show documentation
Common Library of ipokerface
package cn.ipokerface.common.validation.validator;
import cn.ipokerface.common.validation.constraint.NotEmpty;
import java.util.Collection;
import java.util.Map;
/**
* Created by PokerFace
* Create Date 2019-11-25.
* Email: [email protected]
* Version 1.0.0
*
* Description:
*/
public class NotEmptyConstraintValidator implements ConstraintValidator {
public boolean validate(Object value, NotEmpty constraintAnnotation) {
if (value == null){
return false;
}
else if (value instanceof Collection){
return ((Collection) value).size() > 0;
}
else if (value instanceof Map){
return ((Map) value).size() > 0;
}
else if (value instanceof String) {
return ((String) value).length() > 0;
}
return true;
}
}