org.minijax.validator.MinijaxConstraintViolation Maven / Gradle / Ivy
package org.minijax.validator;
import javax.validation.ConstraintViolation;
import javax.validation.Path;
import javax.validation.metadata.ConstraintDescriptor;
public class MinijaxConstraintViolation implements ConstraintViolation {
private final T rootBean;
private final Path propertyPath;
private final Object invalidValue;
private final ConstraintDescriptor> constraintDescriptor;
private final String message;
public MinijaxConstraintViolation(
final T rootBean,
final Path propertyPath,
final Object invalidValue,
final ConstraintDescriptor> constraintDescriptor) {
this.rootBean = rootBean;
this.propertyPath = propertyPath;
this.invalidValue = invalidValue;
this.constraintDescriptor = constraintDescriptor;
message = MinijaxMessageInterpolator.generateMessage(
constraintDescriptor.getMessageTemplate(),
constraintDescriptor.getAnnotation(),
invalidValue);
}
@Override
public T getRootBean() {
return rootBean;
}
@Override
@SuppressWarnings("unchecked")
public Class getRootBeanClass() {
return (Class) rootBean.getClass();
}
@Override
public Path getPropertyPath() {
return propertyPath;
}
@Override
public Object getInvalidValue() {
return invalidValue;
}
@Override
public ConstraintDescriptor> getConstraintDescriptor() {
return constraintDescriptor;
}
@Override
public String getMessageTemplate() {
return constraintDescriptor.getMessageTemplate();
}
@Override
public String getMessage() {
return message;
}
@Override
public String toString() {
return propertyPath + " " + message;
}
/*
* Not implemented
*/
@Override
public Object getLeafBean() {
throw new UnsupportedOperationException();
}
@Override
public Object[] getExecutableParameters() {
throw new UnsupportedOperationException();
}
@Override
public Object getExecutableReturnValue() {
throw new UnsupportedOperationException();
}
@Override
public U unwrap(final Class type) {
throw new UnsupportedOperationException();
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy