
com.itranswarp.jsonstream.validator.impl.BooleanValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsonstream Show documentation
Show all versions of jsonstream Show documentation
Fast JSON serializer/deserializer with JavaBean bindings and validations.
package com.itranswarp.jsonstream.validator.impl;
import java.lang.reflect.AnnotatedElement;
import com.itranswarp.jsonstream.JsonValidateException;
import com.itranswarp.jsonstream.annotation.Required;
import com.itranswarp.jsonstream.validator.Validator;
/**
* A BooleanValidator.
*
* @author Michael Liao
*/
public class BooleanValidator implements Validator {
final boolean required;
public BooleanValidator(AnnotatedElement ae) {
required = ae.isAnnotationPresent(Required.class);
}
public void validate(Boolean obj, String path, String name) {
if (required && obj == null) {
throw new JsonValidateException("Required", path + "." + name);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy