本文整理汇总了Java中com.fasterxml.jackson.databind.exc.InvalidFormatException.Reference方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidFormatException.Reference方法的具体用法?Java InvalidFormatException.Reference怎么用?Java InvalidFormatException.Reference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.fasterxml.jackson.databind.exc.InvalidFormatException
的用法示例。
在下文中一共展示了InvalidFormatException.Reference方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleInputNotReadableException
import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
@ExceptionHandler({HttpMessageNotReadableException.class, InvalidJsonException.class, InvalidFormatException.class})
@ResponseStatus(value = HttpStatus.BAD_REQUEST)
public ResponseError handleInputNotReadableException(Exception exception) {
final Throwable cause = exception.getCause() == null ? exception : exception.getCause();
if (cause instanceof UnrecognizedPropertyException) {
return constructError("error.invalid_json_key", ((UnrecognizedPropertyException) cause).getPropertyName());
} else if (cause instanceof InvalidTypeIdException
|| (cause instanceof JsonMappingException && cause.getMessage()
.contains("missing property 'type'"))) {
return constructError("error.invalid_type_with_set_prompt");
} else if (cause instanceof InvalidFormatException) {
for (InvalidFormatException.Reference reference : ((InvalidFormatException) cause)
.getPath()) {
if ("operations".equals(reference.getFieldName())) {
return constructError("error.permission.invalid_operation");
}
}
}
return badRequestResponse();
}
示例2: buildPropertyPath
import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
/**
* Build and return a property path of given exception.
*/
private StringBuilder buildPropertyPath(final List<InvalidFormatException.Reference> path) {
final StringBuilder propertyPath = new StringBuilder();
InvalidFormatException.Reference parent = null;
for (final InvalidFormatException.Reference reference : path) {
buildPropertyPath(propertyPath, reference, parent);
parent = reference;
}
return propertyPath;
}
示例3: buildNestedPropertyPath
import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
/**
* Build nested property path.
*/
private void buildNestedPropertyPath(final StringBuilder propertyPath, final InvalidFormatException.Reference reference) {
if (reference.getIndex() > -1) {
propertyPath.append('[');
propertyPath.append(reference.getIndex());
propertyPath.append(']');
} else {
propertyPath.append('.');
}
}