當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。