Class ConstraintViolationBean

java.lang.Object
jp.ecuacion.lib.core.jakartavalidation.bean.ConstraintViolationBean

public class ConstraintViolationBean extends Object
Stores 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 Details

    • ConstraintViolationBean

      public ConstraintViolationBean(Object rootBean, String message, String validatorClass, String rootRecordNameForForm, String itemPropertyPath)
      Constructs a new instance with parameters, not a ConstraintViolation.

      This is used for NotEmpty validation logic.

    • ConstraintViolationBean

      public ConstraintViolationBean(jakarta.validation.ConstraintViolation<?> cv)
      Constructs a new instance with ConstraintViolation.
      Parameters:
      cv - ConstraintViolation
  • Method Details

    • getRootBean

      public Object getRootBean()
    • getLeafBean

      public Object getLeafBean()
    • getOriginalMessage

      public String getOriginalMessage()
      Gets message created by jakarta validation.

      DO NOT USE for user interface. Use the message obtained by ExceptionUtil instead.

      Returns:
      original message
    • getValidatorClass

      public String getValidatorClass()
    • getInvalidValue

      public String getInvalidValue()
    • getMessageId

      @Nonnull public String getMessageId()
    • getRootRecordNameForForm

      public String getRootRecordNameForForm()
    • getFieldInfoBeanList

      public List<ConstraintViolationBean.FieldInfoBean> getFieldInfoBeanList()
    • getFieldInfoBeans

      public ConstraintViolationBean.FieldInfoBean[] getFieldInfoBeans()
    • getParamMap

      @Nonnull public Map<String,Object> 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

      protected static Object getFieldValue(String propertyPath, Object instance)
      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