Class ConstraintViolationBean
ConstraintViolation info.
The reason of the existence of the class is that the violations
which are not created by Jakarata Validation can also be treated
just like the one created by Jakarata Validation.
-
Constructor Summary
ConstructorsConstructorDescriptionConstraintViolationBean(jakarta.validation.ConstraintViolation<?> cv) Constructs a new instance withConstraintViolation.ConstraintViolationBean(Object rootBean, String message, String validatorClass, String rootRecordNameForForm, String itemPropertyPath) Constructs a new instance with parameters, not a ConstraintViolation. -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldObtains a field with any scopes and searches fields in super classes.protected static ObjectgetFieldValue(String itemPropertyPath, Object instance) Obtains a field value with any scopes and searches fields in super classes.String[]String[]String[]Gets message created by jakarta validation.static <A extends Annotation>
Optional<A> searchAnnotationPlacedAtClass(Class<?> classOfTargetInstance, Class<A> annotation) Searches for a class annotation in the argument class and its superClasses.
-
Constructor Details
-
ConstraintViolationBean
-
ConstraintViolationBean
public ConstraintViolationBean(jakarta.validation.ConstraintViolation<?> cv) Constructs a new instance withConstraintViolation.- Parameters:
cv- ConstraintViolation
-
-
Method Details
-
getRootBean
-
getLeafBean
-
getOriginalMessage
Gets message created by jakarta validation.DO NOT USE for user interface. Use the message obtained by ExceptionUtil instead.
- Returns:
- original message
-
getValidatorClass
-
getMessageTemplate
-
getFullPropertyPaths
-
getInvalidValue
-
getMessageId
-
getRootRecordNameForForm
-
getItemPropertyPathsForForm
-
getItemNameKeys
-
getParamMap
-
searchAnnotationPlacedAtClass
public static <A extends Annotation> Optional<A> searchAnnotationPlacedAtClass(Class<?> classOfTargetInstance, Class<A> annotation) Searches for a class annotation in the argument class and its superClasses.The search starts at the argument instance, and if it doesn't have the annotation, It searches the superClass of the instance next.
And if it continues to search the annotation and it reaches to Object.class, it stops to search and returns empty Optional.Search ends when it founds the first annotation. Even if there is another anntation of same class, it ignores and it returns first-found annotation.
-
getFieldValue
Obtains a field value with any scopes and searches fields in super classes.Since Class#getDeclaredField is used in the method, making its scope public causes a spotbugs error.
That's why its scope is protected and when you use it you need to extend this class.Public method jp.ecuacion.lib.core.util.internal.PrivateFieldReadUtil.getFieldValue(String, Object, String) uses reflection to modify a field it gets in its parameter which could increase the accessibility of any class. REFLF_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_FIELD -
getField
Obtains a field with any scopes and searches fields in super classes.Since Class#getDeclaredField is used in the method, making its scope public causes a spotbugs error.
That's why its scope is protected and when you use it you need to extend this class.Public method jp.ecuacion.lib.core.util.internal.PrivateFieldReadUtil.getFieldValue(String, Object, String) uses reflection to modify a field it gets in its parameter which could increase the accessibility of any class. REFLF_REFLECTION_MAY_INCREASE_ACCESSIBILITY_OF_FIELD- Parameters:
fieldName- fieldNameclassOfTargetInstance- classOfTargetInstance- Returns:
Pair<Field, Object>left-hand side is the obtained field, right-hand side is its instance. When you set "dept.name" to fieldName, instance would be "dept".
-