com.alogient.cameleon.sdk.content.validator.CmsConstraintViolationUtil Maven / Gradle / Ivy
The newest version!
package com.alogient.cameleon.sdk.content.validator;
import com.alogient.cameleon.sdk.content.model.AbstractCameleonModel;
import com.alogient.cameleon.sdk.content.ui.injection.CameleonModel;
import javax.validation.ConstraintViolation;
import java.lang.annotation.Annotation;
public class CmsConstraintViolationUtil {
public static final String START_OF_ANNOTATION_NAME = "CameleonModel";
public static AbstractCameleonModel getRootModelBean(final ConstraintViolation> violation) {
return (AbstractCameleonModel)violation.getRootBean();
}
public static AbstractCameleonModel getLeafModelBean(final ConstraintViolation> violation) {
return (AbstractCameleonModel)violation.getLeafBean();
}
public static String getCmsTemplateName(final ConstraintViolation> violation) {
return violation.getLeafBean().getClass().getAnnotation(CameleonModel.class).templateName();
}
public static String getCmsTemplateName(final Class> clazz) {
return clazz.getAnnotation(CameleonModel.class).templateName();
}
public static String getModelAnnotationNameEnd(final Annotation cameleonModel) {
return cameleonModel.annotationType().getSimpleName().substring(START_OF_ANNOTATION_NAME.length());
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy