Java Code Examples for com.fasterxml.jackson.databind.util.ClassUtil#nameOf()

The following examples show how to use com.fasterxml.jackson.databind.util.ClassUtil#nameOf() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: StdDeserializer.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method called to get a description of type into which a scalar value coercion
 * is (most likely) being applied, to be used for constructing exception messages
 * on coerce failure.
 *
 * @return Message with backtick-enclosed name of type this deserializer supports
 *
 * @since 2.9
 */
protected String _coercedTypeDesc() {
    boolean structured;
    String typeDesc;

    JavaType t = getValueType();
    if ((t != null) && !t.isPrimitive()) {
        structured = (t.isContainerType() || t.isReferenceType());
        // 21-Jul-2017, tatu: Probably want to change this (JavaType.toString() not very good) but...
        typeDesc = "'"+t.toString()+"'";
    } else {
        Class<?> cls = handledType();
        structured = cls.isArray() || Collection.class.isAssignableFrom(cls)
            || Map.class.isAssignableFrom(cls);
        typeDesc = ClassUtil.nameOf(cls);
    }
    if (structured) {
        return "as content of type "+typeDesc;
    }
    return "for type "+typeDesc;
}
 
Example 2
Source File: SerializerProvider.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Helper method called to indicate problem in POJO (serialization) definitions or settings
 * regarding specific property (of a type), unrelated to actual JSON content to map.
 * Default behavior is to construct and throw a {@link JsonMappingException}.
 *
 * @since 2.9
 */
public <T> T reportBadPropertyDefinition(BeanDescription bean, BeanPropertyDefinition prop,
        String message, Object... msgArgs) throws JsonMappingException {
    message = _format(message, msgArgs);
    String propName = "N/A";
    if (prop != null) {
        propName = _quotedString(prop.getName());
    }
    String beanDesc = "N/A";
    if (bean != null) {
        beanDesc = ClassUtil.nameOf(bean.getBeanClass());
    }
    message = String.format("Invalid definition for property %s (of type %s): %s",
            propName, beanDesc, message);
    throw InvalidDefinitionException.from(getGenerator(), message, bean, prop);
}
 
Example 3
Source File: ObjectIdInfo.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
    return "ObjectIdInfo: propName="+_propertyName
            +", scope="+ClassUtil.nameOf(_scope)
            +", generatorType="+ClassUtil.nameOf(_generator)
            +", alwaysAsId="+_alwaysAsId;
}
 
Example 4
Source File: SerializerProvider.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Helper method called to indicate problem in POJO (serialization) definitions or settings
 * regarding specific Java type, unrelated to actual JSON content to map.
 * Default behavior is to construct and throw a {@link JsonMappingException}.
 *
 * @since 2.9
 */
public <T> T reportBadTypeDefinition(BeanDescription bean,
        String msg, Object... msgArgs) throws JsonMappingException {
    String beanDesc = "N/A";
    if (bean != null) {
        beanDesc = ClassUtil.nameOf(bean.getBeanClass());
    }
    msg = String.format("Invalid type definition for type %s: %s",
            beanDesc, _format(msg, msgArgs));
    throw InvalidDefinitionException.from(getGenerator(), msg, bean, null);
}
 
Example 5
Source File: StdValueInstantiator.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * @deprecated Since 2.7 use constructor that takes {@link JavaType} instead
 */
@Deprecated
public StdValueInstantiator(DeserializationConfig config, Class<?> valueType) {
    _valueTypeDesc = ClassUtil.nameOf(valueType);
    _valueClass = (valueType == null) ? Object.class : valueType;
}