package org.gcube.accounting.datamodel.validators; import java.io.Serializable; import org.gcube.accounting.datamodel.annotations.NotNull; import org.gcube.accounting.exception.InvalidValueException; public class NotNullValidator implements FieldValidator{ public Class annotation() { return NotNull.class; } public boolean isValid(Serializable toValidate) { return toValidate!=null; } public Serializable validate(Serializable toValidate) throws InvalidValueException { if(isValid(toValidate)){ return toValidate; } throw new InvalidValueException(getErrorSuffix()); } public String getErrorSuffix() { return "is null"; } }