javax.validation.constraints.NotBlank的实例源码

项目:minijax    文件MinijaxConstraintDescriptor.java   
private static MinijaxConstraintDescriptor<NotBlank> buildNotBlankValidator(final NotBlank notBlank,final Class<?> valueClass) {
    if (CharSequence.class.isAssignableFrom(valueClass)) {
        return new MinijaxConstraintDescriptor<>(notBlank,NotBlankValidator.INSTANCE);
    }

    throw new ValidationException("Unsupported type for @NotBlank annotation: " + valueClass);
}
项目:POC    文件CustomerController.java   
/**
 * Get customer using id. Returns HTTP 404 if customer not found
 *
 * @param customerId a {@link java.lang.Long} object.
 * @return retrieved customer
 * @throws com.poc.restfulpoc.exception.EntityNotFoundException if any.
 */
@GetMapping(value = "/rest/customers/{customerId}",produces = {
        MediaType.APPLICATION_JSON_VALUE,MediaType.APPLICATION_XML_VALUE })
public ResponseEntity<Customer> getCustomer(
        @PathVariable("customerId") @NotBlank Long customerId)
        throws EntityNotFoundException {
    log.info("Fetching Customer with id {}",customerId);
    final Customer user = customerService.getCustomer(customerId);
    if (user == null) {
        log.error("Customer with id {} not found",customerId);
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
    return new ResponseEntity<>(user,HttpStatus.OK);
}
项目:minijax    文件MinijaxConstraintDescriptor.java   
@SuppressWarnings("unchecked")
public static <T extends Annotation> MinijaxConstraintDescriptor<T> build(final AnnotatedType annotatedType,final T annotation) {
    final Constraint constraint = annotation.annotationType().getAnnotation(Constraint.class);
    if (constraint == null) {
        return null;
    }

    final Class<?> valueClass = ReflectionUtils.getRawType(annotatedType);
    final Class<?> annotationClass = annotation.annotationType();

    if (constraint.validatedBy().length > 0) {
        return buildDeclaredValidator(annotation,constraint.validatedBy()[0]);

    } else if (annotationClass == AssertFalse.class) {
        return (MinijaxConstraintDescriptor<T>) buildAssertFalseValidator((AssertFalse) annotation,valueClass);

    } else if (annotationClass == AssertTrue.class) {
        return (MinijaxConstraintDescriptor<T>) buildAssertTrueValidator((AssertTrue) annotation,valueClass);

    } else if (annotationClass == Max.class) {
        return (MinijaxConstraintDescriptor<T>) buildMaxValidator((Max) annotation,valueClass);

    } else if (annotationClass == Min.class) {
        return (MinijaxConstraintDescriptor<T>) buildMinValidator((Min) annotation,valueClass);

    } else if (annotationClass == NotBlank.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotBlankValidator((NotBlank) annotation,valueClass);

    } else if (annotationClass == NotEmpty.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotEmptyValidator((NotEmpty) annotation,valueClass);

    } else if (annotationClass == NotNull.class) {
        return (MinijaxConstraintDescriptor<T>) buildNotNullValidator((NotNull) annotation);

    } else if (annotationClass == Pattern.class) {
        return (MinijaxConstraintDescriptor<T>) buildPatternValidator((Pattern) annotation,valueClass);

    } else if (annotationClass == Size.class) {
        return (MinijaxConstraintDescriptor<T>) buildSizeValidator((Size) annotation,valueClass);

    } else {
        throw new ValidationException("Unrecognized constraint annotation: " + annotation);
    }
}
项目:lastaflute    文件ExecuteMethodValidatorChecker.java   
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();
}
项目:molgenis    文件AutoTagRequest.java   
@NotBlank
public abstract String getEntityTypeId();
项目:molgenis    文件GetontologyTermRequest.java   
@NotBlank
public abstract String getSearchTerm();
项目:molgenis    文件FeedbackController.java   
@NotBlank
public String getFeedback()
{
    return Feedback;
}

相关文章

买水果
比较全面的redis工具类
gson 反序列化到多态子类
java 版本的 mb_strwidth
JAVA 反转字符串的最快方法,大概比StringBuffer.reverse()性...
com.google.gson.internal.bind.ArrayTypeAdapter的实例源码...