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


Java InvalidFormatException.from方法代码示例

本文整理汇总了Java中com.fasterxml.jackson.databind.exc.InvalidFormatException.from方法的典型用法代码示例。如果您正苦于以下问题:Java InvalidFormatException.from方法的具体用法?Java InvalidFormatException.from怎么用?Java InvalidFormatException.from使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.fasterxml.jackson.databind.exc.InvalidFormatException的用法示例。


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

示例1: deserialize

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
@Override
public ListResource<T> deserialize(JsonParser parser, DeserializationContext ctxt) throws IOException {
    JsonNode node = parser.getCodec().readTree(parser);

    // Find the first unrecognised field that is an array
    Optional<Map.Entry<String, JsonNode>> field = CommonUtil.stream(node.fields())
            .filter(f -> !RECOGNISED_KEYS.contains(f.getKey()))
            .filter(f -> f.getValue().isArray())
            // There might be multiple fields that are arrays, so we pick the first one and ignore the others
            .sorted().findFirst();

    if (!field.isPresent()) {
        throw InvalidFormatException.from(parser, ListResource.class, "Expected a field containing a list");
    }

    String key = field.get().getKey();
    JsonNode value = field.get().getValue();
    List<T> items = value.traverse().readValueAs(new TypeReference<List<T>>(){});

    Link selfLink = node.get("@id").traverse().readValueAs(Link.class);
    return ListResource.create(selfLink, key, items);
}
 
开发者ID:graknlabs,项目名称:grakn,代码行数:23,代码来源:ListResource.java

示例2: weirdKeyException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
/**
 * Helper method for constructing exception to indicate that given JSON
 * Object field name was not in format to be able to deserialize specified
 * key type.
 */
public JsonMappingException weirdKeyException(Class<?> keyClass, String keyValue, String msg)
{
    return InvalidFormatException.from(_parser,
            "Can not construct Map key of type "+keyClass.getName()+" from String \""+_desc(keyValue)+"\": "+msg,
            keyValue, keyClass);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:12,代码来源:DeserializationContext.java

示例3: weirdKeyException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
public JsonMappingException weirdKeyException(Class<?> paramClass, String paramString1, String paramString2)
{
  return InvalidFormatException.from(this._parser, "Can not construct Map key of type " + paramClass.getName() + " from String \"" + _desc(paramString1) + "\": " + paramString2, paramString1, paramClass);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:DeserializationContext.java

示例4: weirdNumberException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
public JsonMappingException weirdNumberException(Number paramNumber, Class<?> paramClass, String paramString)
{
  return InvalidFormatException.from(this._parser, "Can not construct instance of " + paramClass.getName() + " from number value (" + _valueDesc() + "): " + paramString, null, paramClass);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:DeserializationContext.java

示例5: weirdStringException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
public JsonMappingException weirdStringException(String paramString1, Class<?> paramClass, String paramString2)
{
  return InvalidFormatException.from(this._parser, "Can not construct instance of " + paramClass.getName() + " from String value '" + _valueDesc() + "': " + paramString2, paramString1, paramClass);
}
 
开发者ID:mmmsplay10,项目名称:QuizUpWinner,代码行数:5,代码来源:DeserializationContext.java

示例6: weirdNumberException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
/**
 * Helper method for constructing exception to indicate that input JSON
 * Number was not suitable for deserializing into given target type.
 */
public JsonMappingException weirdNumberException(Number value, Class<?> instClass, String msg) {
    return InvalidFormatException.from(_parser,
            "Can not construct instance of "+instClass.getName()+" from number value ("+_valueDesc()+"): "+msg,
            null, instClass);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:10,代码来源:DeserializationContext.java

示例7: weirdStringException

import com.fasterxml.jackson.databind.exc.InvalidFormatException; //导入方法依赖的package包/类
/**
 * Method that will construct an exception suitable for throwing when
 * some String values are acceptable, but the one encountered is not.
 * 
 * @param value String value from input being deserialized
 * @param instClass Type that String should be deserialized into
 * @param msg Message that describes specific problem
 * 
 * @since 2.1
 */
public JsonMappingException weirdStringException(String value, Class<?> instClass, String msg) {
    return InvalidFormatException.from(_parser,
            "Can not construct instance of "+instClass.getName()+" from String value '"+_valueDesc()+"': "+msg,
            value, instClass);
}
 
开发者ID:joyplus,项目名称:joyplus-tv,代码行数:16,代码来源:DeserializationContext.java


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