当前位置: 首页>>代码示例>>Java>>正文


Java Required类代码示例

本文整理汇总了Java中org.lastaflute.web.validation.Required的典型用法代码示例。如果您正苦于以下问题:Java Required类的具体用法?Java Required怎么用?Java Required使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Required类属于org.lastaflute.web.validation包,在下文中一共展示了Required类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: test_signin_validationError_required

import org.lastaflute.web.validation.Required; //导入依赖的package包/类
public void test_signin_validationError_required() {
    // ## Arrange ##
    SigninAction action = new SigninAction();
    inject(action);
    SigninForm form = new SigninForm();

    // ## Act ##
    // ## Assert ##
    assertValidationError(() -> action.signin(form)).handle(data -> {
        data.requiredMessageOf("account", Required.class);
        data.requiredMessageOf("password", Required.class);
        TestingHtmlData htmlData = validateHtmlData(data.hookError());
        htmlData.assertHtmlForward(HarborHtmlPath.path_Signin_SigninHtml);
    });
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:16,代码来源:SigninActionTest.java

示例2: getConstraintDescriptor

import org.lastaflute.web.validation.Required; //导入依赖的package包/类
@Required
@Override
public ConstraintDescriptor<?> getConstraintDescriptor() {
    String methodName = "getConstraintDescriptor";
    Method method;
    try {
        method = MockConstraintViolation.class.getMethod(methodName, new Class<?>[] {});
    } catch (NoSuchMethodException | SecurityException e) {
        throw new IllegalStateException("Failed to get the method: " + methodName, e);
    }
    Required annotation = method.getAnnotation(Required.class);
    return new ConstraintDescriptor<Annotation>() {

        @Override
        public Annotation getAnnotation() {
            return annotation;
        }

        @Override
        public String getMessageTemplate() {
            return null;
        }

        @Override
        public Set<Class<?>> getGroups() {
            return DfCollectionUtil.newHashSet(ClientError.class);
        }

        @Override
        public Set<Class<? extends Payload>> getPayload() {
            return null;
        }

        @Override
        public ConstraintTarget getValidationAppliesTo() {
            return null;
        }

        @Override
        public List<Class<? extends ConstraintValidator<Annotation, ?>>> getConstraintValidatorClasses() {
            return null;
        }

        @Override
        public Map<String, Object> getAttributes() {
            return null;
        }

        @Override
        public Set<ConstraintDescriptor<?>> getComposingConstraints() {
            return null;
        }

        @Override
        public boolean isReportAsSingleViolation() {
            return false;
        }

        @Override
        public ValidateUnwrappedValue getValueUnwrapping() {
            return null;
        }

        @Override
        public <U> U unwrap(Class<U> type) {
            return null;
        }
    };
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:70,代码来源:MockConstraintViolation.java

示例3: doCheckMismatchedValidatorAnnotation

import org.lastaflute.web.validation.Required; //导入依赖的package包/类
protected void doCheckMismatchedValidatorAnnotation(Field field, Map<String, Class<?>> genericMap) { // recursive point
    pathDeque.push(field.getName());
    checkedTypeSet.add(field.getDeclaringClass());
    final Class<?> fieldType = deriveFieldType(field, genericMap);
    // *depends on JSON rule so difficult, check only physical mismatch here
    //if (isFormPropertyCannotNotNullType(fieldType)) {
    //    final Class<NotNull> notNullType = NotNull.class;
    //    if (field.getAnnotation(notNullType) != null) {
    //        throwExecuteMethodFormPropertyValidationMismatchException(property, notNullType);
    //    }
    //}
    if (isCannotNotEmptyType(fieldType)) {
        final Class<NotEmpty> notEmptyType = NotEmpty.class;
        if (field.getAnnotation(notEmptyType) != null) {
            throwExecuteMethodNotEmptyValidationMismatchException(field, notEmptyType);
        }
    }
    if (isCannotNotBlankType(fieldType)) {
        final Class<NotBlank> notBlankType = NotBlank.class;
        if (field.getAnnotation(notBlankType) != null) {
            throwExecuteMethodNotEmptyValidationMismatchException(field, notBlankType);
        }
    }
    if (isFormPropertyCannotRequiredPrimitiveType(fieldType)) {
        final Class<Required> requiredType = Required.class;
        if (field.getAnnotation(requiredType) != null) {
            throwExecuteMethodPrimitiveValidationMismatchException(field, requiredType);
        }
        final Class<NotNull> notNullType = NotNull.class;
        if (field.getAnnotation(notNullType) != null) {
            throwExecuteMethodPrimitiveValidationMismatchException(field, notNullType);
        }
    }
    if (Collection.class.isAssignableFrom(fieldType)) { // only collection, except array and map, simply
        doCheckGenericBeanValidationMismatch(field);
    } else if (mayBeNestedBeanType(fieldType)) {
        doCheckNestedValidationMismatch(fieldType);
        doCheckGenericBeanValidationMismatch(field);
    }
    pathDeque.pop();
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:42,代码来源:ExecuteMethodValidatorChecker.java


注:本文中的org.lastaflute.web.validation.Required类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。