本文整理汇总了Java中javax.validation.constraints.NotBlank类的典型用法代码示例。如果您正苦于以下问题:Java NotBlank类的具体用法?Java NotBlank怎么用?Java NotBlank使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
NotBlank类属于javax.validation.constraints包,在下文中一共展示了NotBlank类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildNotBlankValidator
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
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);
}
示例2: getCustomer
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
/**
* 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);
}
示例3: getEntityTypeId
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
@NotBlank
public abstract String getEntityTypeId();
示例4: getSearchTerm
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
@NotBlank
public abstract String getSearchTerm();
示例5: getFeedback
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
@NotBlank
public String getFeedback()
{
return feedback;
}
示例6: build
import javax.validation.constraints.NotBlank; //导入依赖的package包/类
@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);
}
}
示例7: doCheckMismatchedValidatorAnnotation
import javax.validation.constraints.NotBlank; //导入依赖的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();
}